summaryrefslogtreecommitdiff
path: root/copybump.py
diff options
context:
space:
mode:
authorBarry Warsaw2015-07-31 17:20:40 -0400
committerBarry Warsaw2015-07-31 17:20:40 -0400
commit39e55cff34f2556f5fca7c50fb05196fbec03aa6 (patch)
tree9e03ec3e98a82eb2e3baa43aa8d535c95a462d5f /copybump.py
parentd903aa4ba57dc19699972bf22b7874edd90434a8 (diff)
downloadmailman-39e55cff34f2556f5fca7c50fb05196fbec03aa6.tar.gz
mailman-39e55cff34f2556f5fca7c50fb05196fbec03aa6.tar.zst
mailman-39e55cff34f2556f5fca7c50fb05196fbec03aa6.zip
Diffstat (limited to 'copybump.py')
-rwxr-xr-xcopybump.py23
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)