summaryrefslogtreecommitdiff
path: root/copybump.py
diff options
context:
space:
mode:
authorBarry Warsaw2009-12-27 13:21:28 -0500
committerBarry Warsaw2009-12-27 13:21:28 -0500
commit16bf4d15972351c3f8dacc7f28c4cdb24a717e59 (patch)
treee6abad3ad407260b85156b828441e37b0374d7a5 /copybump.py
parent7592ba511e37a299e3329f95e584873f3613dc5f (diff)
downloadmailman-16bf4d15972351c3f8dacc7f28c4cdb24a717e59.tar.gz
mailman-16bf4d15972351c3f8dacc7f28c4cdb24a717e59.tar.zst
mailman-16bf4d15972351c3f8dacc7f28c4cdb24a717e59.zip
Diffstat (limited to 'copybump.py')
-rwxr-xr-xcopybump.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/copybump.py b/copybump.py
new file mode 100755
index 000000000..0b9bdf6b9
--- /dev/null
+++ b/copybump.py
@@ -0,0 +1,27 @@
+#! /usr/bin/env python3
+
+import os
+import re
+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})')
+
+
+def do_file(path):
+ with open(path) as in_file, open(path + '.out', 'w') as out_file:
+ for line in in_file:
+ mo = pyre.match(line)
+ if mo is None:
+ out_file.write(line)
+ continue
+ start = (mo.group('end')
+ if mo.group('start') is None
+ else mo.group('start'))
+ print('# Copyright (C) {}-{} {}'.format(
+ mo.group('end'), this_year, FSF), file=out_file)
+ for line in in_file:
+ out_file.write(line)
+ os.rename(path + '.out', path)