3 # This uses the output from "support/git-set-file-times --list" to discern
4 # the last-modified year of each *.c & *.h file and updates the copyright
5 # year if it isn't set right.
7 import sys, os, re, argparse, subprocess
8 from datetime import datetime
13 proc = subprocess.Popen('support/git-set-file-times --list'.split(), stdout=subprocess.PIPE, encoding='utf-8')
14 for line in proc.stdout:
15 m = re.match(r'^\S\s+(?P<year>\d\d\d\d)\S+\s+\S+\s+(?P<fn>.+)', line)
17 print("Failed to parse line from git-set-file-times:", line)
19 m = argparse.Namespace(**m.groupdict())
20 if m.year > latest_year:
25 with open(fn, 'r', encoding='utf-8') as fh:
28 txt = f'#define LATEST_YEAR "{latest_year}"\n'
30 print(f"Updating {fn} with year {latest_year}")
31 with open(fn, 'w', encoding='utf-8') as fh:
35 if __name__ == '__main__':
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.")
37 args = parser.parse_args()