55
66 See VersionUpdate.py -h for help
77
8- Copyright (C) 2015-2017 The Gregorio Project (see CONTRIBUTORS.md)
8+ Copyright (C) 2015-2018 The Gregorio Project (see CONTRIBUTORS.md)
99
1010 This file is part of Gregorio.
1111
3232import time
3333import os
3434import locale
35+ import linecache
3536from datetime import date
3637
3738from distutils .util import strtobool
4142os .chdir (sys .path [0 ])
4243
4344VERSION_FILE = '.gregorio-version'
45+ CURRENTYEAR = str (date .today ().year )
4446GREGORIO_FILES = ["configure.ac" ,
4547 "ctan-o-mat.config" ,
4648 "windows/gregorio-resources.rc" ,
6567 "tex/gregoriotex-common.tex" ,
6668 "fonts/squarize.py" ,
6769 ]
70+ COPYRIGHT_FILES = ["install-gtex.sh" ,
71+ "tex/gregoriotex-signs.tex" ,
72+ "tex/gregorio-vowels.dat" ,
73+ "tex/gsp-default.tex" ,
74+ "tex/gregoriotex-nabc.lua" ,
75+ "tex/gregoriotex-symbols.lua" ,
76+ "tex/gregoriotex-chars.tex" ,
77+ "tex/gregoriotex-main.tex" ,
78+ "tex/gregoriotex-spaces.tex" ,
79+ "tex/Makefile.am" ,
80+ "tex/gregoriotex-common.tex" ,
81+ "tex/gregoriotex-syllable.tex" ,
82+ "tex/gregoriotex.lua" ,
83+ "tex/gregoriotex.sty" ,
84+ "tex/gregoriosyms.sty" ,
85+ "tex/gregoriotex-nabc.tex" ,
86+ "tex/gregoriotex.tex" ,
87+ "tex/gregoriotex-signs.lua" ,
88+ "tex/gregoriotex-symbols.tex" ,
89+ "contrib/TeXShop/Makefile.am" ,
90+ "contrib/900_gregorio.xml" ,
91+ "contrib/Makefile.am" ,
92+ "contrib/gabc.lang" ,
93+ "contrib/gprocess" ,
94+ "contrib/checkSyllabation.py" ,
95+ "configure.ac" ,
96+ "examples/Makefile.am" ,
97+ "Makefile.am" ,
98+ "install.sh" ,
99+ "debian/copyright" ,
100+ "debian/copyright" ,
101+ "doc/Command_Index_User.tex" ,
102+ "doc/Makefile.am" ,
103+ "doc/GregorioRef.tex" ,
104+ "doc/Command_Index_gregorio.tex" ,
105+ "doc/Command_Index_internal.tex" ,
106+ "doc/GregorioNabcRef.tex" ,
107+ "doc/Gabc.tex" ,
108+ "doc/GregorioRef.lua" ,
109+ "doc/Appendix_Font_Tables.tex" ,
110+ "VersionManager.py" ,
111+ "coverage.sh" ,
112+ "COPYING.md" ,
113+ "src/characters.h" ,
114+ "src/plugins.h" ,
115+ "src/gregoriotex/gregoriotex-write.c" ,
116+ "src/gregoriotex/gregoriotex.h" ,
117+ "src/gregoriotex/gregoriotex-position.c" ,
118+ "src/unicode.c" ,
119+ "src/unicode.h" ,
120+ "src/messages.h" ,
121+ "src/support.c" ,
122+ "src/sha1.h" ,
123+ "src/messages.c" ,
124+ "src/support.h" ,
125+ "src/sha1.c" ,
126+ "src/struct.h" ,
127+ "src/bool.h" ,
128+ "src/struct_iter.h" ,
129+ "src/Makefile.am" ,
130+ "src/dump/dump.c" ,
131+ "src/encode_utf8strings.c" ,
132+ "src/enum_generator.h" ,
133+ "src/gabc/gabc-score-determination.c" ,
134+ "src/gabc/gabc-elements-determination.c" ,
135+ "src/gabc/gabc-write.c" ,
136+ "src/gabc/gabc-notes-determination.l" ,
137+ "src/gabc/gabc.h" ,
138+ "src/gabc/gabc-score-determination.l" ,
139+ "src/gabc/gabc-score-determination.y" ,
140+ "src/gabc/gabc-score-determination.h" ,
141+ "src/gabc/gabc-glyphs-determination.c" ,
142+ "src/utf8strings.h.in" ,
143+ "src/config.h" ,
144+ "src/characters.c" ,
145+ "src/vowel/vowel-rules.y" ,
146+ "src/vowel/vowel.h" ,
147+ "src/vowel/vowel-rules.h" ,
148+ "src/vowel/vowel-rules.l" ,
149+ "src/vowel/vowel.c" ,
150+ "src/gregorio-utils.c" ,
151+ "src/struct.c" ,
152+ "fonts/gregorio-base.sfd" ,
153+ "fonts/granapadano-base.sfd" ,
154+ "fonts/squarize.py" ,
155+ "fonts/convertsfdtottf.py" ,
156+ "fonts/Makefile.am" ,
157+ "fonts/simplify.py" ,
158+ "fonts/stemsschemas.py" ,
159+ "fonts/greciliae-base.sfd" ,
160+ "fonts/gregall.sfd" ,
161+ "fonts/grelaon.sfd" ,
162+ "fonts/gresgmodern.sfd" ,
163+ "fonts/install_supp_fonts.lua" ,
164+ "windows/gregorio.iss" ,
165+ "windows/install.lua" ,
166+ "windows/uninstall.lua" ,
167+ ]
68168
69169def get_parser ():
70170 "Return command line parser"
@@ -119,7 +219,7 @@ class Version(object):
119219
120220 def __init__ (self , versionfile ):
121221 self .versionfile = versionfile
122- self .version = self .read_version ( )
222+ self .version = linecache . getline ( self .versionfile , 1 ). strip ( ' \n ' )
123223 self .filename_version = self .filename_version_from_version (self .version )
124224 self .short_tag = None
125225 self .date = None
@@ -131,19 +231,13 @@ def filename_version_from_version(self, version):
131231
132232 def binary_version_from_version (self , version ):
133233 "Return binary version number for Windows FILEVERSION"
134- bin = version .replace ('.' ,',' )
135- if '-' in bin :
136- bin = bin .replace ('-beta' ,',1' )
137- bin = bin .replace ('-rc' ,',2' )
234+ binary = version .replace ('.' , ',' )
235+ if '-' in binary :
236+ binary = binary .replace ('-beta' , ',1' )
237+ binary = binary .replace ('-rc' , ',2' )
138238 else :
139- bin += ',30'
140- return bin
141-
142- def read_version (self ):
143- "Return version for instance variable"
144- with open (self .versionfile , 'r' ) as verfile :
145- self .grever = verfile .readline ()
146- return self .grever .strip ('\n ' )
239+ binary += ',30'
240+ return binary
147241
148242 def fetch_version (self ):
149243 "Prints version"
@@ -173,7 +267,7 @@ def update_version(self, newversion):
173267 print ('Updating {0} with the new version: {1}\n ' .format (
174268 self .versionfile , self .version ))
175269 with open (self .versionfile , 'w' ) as verfile :
176- verfile .write (self .version )
270+ verfile .write ('{0} \n {1}' . format ( self .version , CURRENTYEAR ) )
177271 verfile .write ('\n \n *** Do not modify this file. ***\n ' )
178272 verfile .write ('Use VersionManager.py to change the version.\n ' )
179273
@@ -332,6 +426,28 @@ def do_release(version_obj, not_interactive):
332426 version_obj .update_version (newversion )
333427 replace_version (version_obj )
334428
429+ def copyright_year ():
430+ "Check and update copyright year as needed"
431+ fileyear = linecache .getline (VERSION_FILE , 2 ).strip ()
432+ if int (fileyear ) != int (CURRENTYEAR ):
433+ print ('Updating copyright year.' )
434+ for myfile in COPYRIGHT_FILES :
435+ result = []
436+ with open (myfile , 'r' ) as infile :
437+ for line in infile :
438+ if re .search (r'[C|c]opyright.*Gregorio Project' , line ):
439+ result .append (re .sub (fileyear , CURRENTYEAR , line ))
440+ elif re .search (r'[C|c]opyright.*Elie Roux' , line ):
441+ result .append (re .sub (fileyear , CURRENTYEAR , line ))
442+ elif re .search (r'[C|c]opyright.*Richard Chonak' , line ):
443+ result .append (re .sub (fileyear , CURRENTYEAR , line ))
444+ elif re .search (r'[C|c]opyright.*Jakub Jelinek' , line ):
445+ result .append (re .sub (fileyear , CURRENTYEAR , line ))
446+ else :
447+ result .append (line )
448+ with open (myfile , 'w' ) as outfile :
449+ outfile .write ('' .join (result ))
450+
335451def main ():
336452 "Main function"
337453 parser = get_parser ()
@@ -349,7 +465,8 @@ def main():
349465 gregorio_version .fetch_version_debian_stable ()
350466 elif args .get_debian_git :
351467 gregorio_version .fetch_version_debian_git ()
352- elif args .beta :
468+ copyright_year ()
469+ if args .beta :
353470 beta (gregorio_version , not_interactive )
354471 elif args .major :
355472 bump_major (gregorio_version , not_interactive )
0 commit comments