diff options
Diffstat (limited to 'copybump.py')
| -rwxr-xr-x | copybump.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/copybump.py b/copybump.py index a4eea59a3..3c91b7a0d 100755 --- a/copybump.py +++ b/copybump.py @@ -9,28 +9,41 @@ import datetime FSF = 'by the Free Software Foundation, Inc.' this_year = datetime.date.today().year -pyre = re.compile(r'# Copyright \(C\) ((?P<start>\d{4})-)?(?P<end>\d{4})') +pyre_c = re.compile(r'# Copyright \(C\) ((?P<start>\d{4})-)?(?P<end>\d{4})') +pyre_n = re.compile(r'# Copyright ((?P<start>\d{4})-)?(?P<end>\d{4})') +new_c = '# Copyright (C) {}-{} {}' +new_n = '# Copyright {}-{} {}' MODE = (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) +if '--noc' in sys.argv: + pyre = pyre_n + new = new_n + sys.argv.remove('--noc') +else: + pyre = pyre_c + new = new_c + + def do_file(path, owner): permissions = os.stat(path).st_mode & MODE with open(path) as in_file, open(path + '.out', 'w') as out_file: try: for line in in_file: - mo = pyre.match(line) - if mo is None: + mo_c = pyre_c.match(line) + mo_n = pyre_n.match(line) + if mo_c is None and mo_n is None: out_file.write(line) continue + mo = (mo_n if mo_c is None else mo_c) start = (mo.group('end') if mo.group('start') is None else mo.group('start')) if int(start) == this_year: out_file.write(line) continue - print('# Copyright (C) {}-{} {}'.format( - start, this_year, owner), file=out_file) + print(new.format(start, this_year, owner), file=out_file) print('=>', path) for line in in_file: out_file.write(line) |
