generate a list of years from 2014 to the current year
@@ -24,6 +24,7 @@ import mmap
import os
import re
import sys
+from datetime import date
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -107,7 +108,7 @@ def file_passes(filename, refs, regexs):
print('File %s is missing the year' % filename, file=verbose_out)
return False
- # Replace all occurrences of the regex "2016|2015|2014" with "YEAR"
+ # Replace all occurrences of the regex "CURRENT_YEAR|...|2016|2015|2014" with "YEAR"
p = regexs["date"]
for i, d in enumerate(data):
(data[i], found) = p.subn('YEAR', d)
@@ -174,8 +175,9 @@ def get_regexs():
regexs = {}
# Search for "YEAR" which exists in the boilerplate, but shouldn't in the real thing
regexs["year"] = re.compile( 'YEAR' )
- # dates can be 2014, 2015 or 2016, company holder names can be anything
- regexs["date"] = re.compile( '(2014|2015|2016)' )
+ # dates can be 2014, 2015, 2016, ..., CURRENT_YEAR, company holder names can be anything
+ years = range(2014, date.today().year + 1)
+ regexs["date"] = re.compile( '(%s)' % "|".join(map(lambda l: str(l), years)) )
# strip // +build \n\n build constraints
regexs["go_build_constraints"] = re.compile(r"^(// \+build.*\n)+\n", re.MULTILINE)
# strip #!.* from shell scripts
