77import sys , os , re , argparse , subprocess
88from datetime import datetime
99
10- MAINTAINER_NAME = 'Wayne Davison'
11- MAINTAINER_SUF = ' ' + MAINTAINER_NAME + "\n "
12-
1310def main ():
1411 latest_year = '2000'
1512
@@ -22,10 +19,6 @@ def main():
2219 m = argparse .Namespace (** m .groupdict ())
2320 if m .year > latest_year :
2421 latest_year = m .year
25- if m .fn .startswith ('zlib/' ) or m .fn .startswith ('popt/' ):
26- continue
27- if re .search (r'\.(c|h|sh|test)$' , m .fn ):
28- maybe_edit_copyright_year (m .fn , m .year )
2922 proc .communicate ()
3023
3124 fn = 'latest-year.h'
@@ -39,55 +32,8 @@ def main():
3932 fh .write (txt )
4033
4134
42- def maybe_edit_copyright_year (fn , year ):
43- opening_lines = [ ]
44- copyright_line = None
45-
46- with open (fn , 'r' , encoding = 'utf-8' ) as fh :
47- for lineno , line in enumerate (fh ):
48- opening_lines .append (line )
49- if lineno > 3 and not re .search (r'\S' , line ):
50- break
51- m = re .match (r'^(?P<pre>.*Copyright\s+\S+\s+)(?P<year>\d\d\d\d(?:-\d\d\d\d)?(,\s+\d\d\d\d)*)(?P<suf>.+)' , line )
52- if not m :
53- continue
54- copyright_line = argparse .Namespace (** m .groupdict ())
55- copyright_line .lineno = len (opening_lines )
56- copyright_line .is_maintainer_line = MAINTAINER_NAME in copyright_line .suf
57- copyright_line .txt = line
58- if copyright_line .is_maintainer_line :
59- break
60-
61- if not copyright_line :
62- return
63-
64- if copyright_line .is_maintainer_line :
65- cyears = copyright_line .year .split ('-' )
66- if year == cyears [0 ]:
67- cyears = [ year ]
68- else :
69- cyears = [ cyears [0 ], year ]
70- txt = copyright_line .pre + '-' .join (cyears ) + MAINTAINER_SUF
71- if txt == copyright_line .txt :
72- return
73- opening_lines [copyright_line .lineno - 1 ] = txt
74- else :
75- if fn .startswith ('lib/' ) or fn .startswith ('testsuite/' ):
76- return
77- txt = copyright_line .pre + year + MAINTAINER_SUF
78- opening_lines [copyright_line .lineno - 1 ] += txt
79-
80- remaining_txt = fh .read ()
81-
82- print (f"Updating { fn } with year { year } " )
83-
84- with open (fn , 'w' , encoding = 'utf-8' ) as fh :
85- fh .write ('' .join (opening_lines ))
86- fh .write (remaining_txt )
87-
88-
8935if __name__ == '__main__' :
90- parser = argparse .ArgumentParser (description = "Grab the year of last mod for our c & h files and make sure the Copyright comment is up-to-date ." )
36+ parser = argparse .ArgumentParser (description = "Grab the year of the last mod for our c & h files and make sure the LATEST_YEAR value is accurate ." )
9137 args = parser .parse_args ()
9238 main ()
9339
0 commit comments