diff options
| author | Barry Warsaw | 2011-07-11 14:30:52 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2011-07-11 14:30:52 -0400 |
| commit | 651fe5ef452e6ae7cba741c819f9fcc994688753 (patch) | |
| tree | afa1537647e4b7b6621f811c9cc8ea958479cb90 | |
| parent | a8722b736a9070288f9bd62b8650f9e682a33ea6 (diff) | |
| download | mailman-651fe5ef452e6ae7cba741c819f9fcc994688753.tar.gz mailman-651fe5ef452e6ae7cba741c819f9fcc994688753.tar.zst mailman-651fe5ef452e6ae7cba741c819f9fcc994688753.zip | |
| -rwxr-xr-x | copybump.py | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/copybump.py b/copybump.py index 82b3a81dc..2f78c79b5 100755 --- a/copybump.py +++ b/copybump.py @@ -2,6 +2,7 @@ import os import re +import sys import stat import datetime @@ -13,7 +14,7 @@ pyre = re.compile(r'# Copyright \(C\) ((?P<start>\d{4})-)?(?P<end>\d{4})') MODE = (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) -def do_file(path): +def do_file(path, owner): print('=>', path) permissions = os.stat(path).st_mode & MODE with open(path) as in_file, open(path + '.out', 'w') as out_file: @@ -27,7 +28,7 @@ def do_file(path): if mo.group('start') is None else mo.group('start')) print('# Copyright (C) {}-{} {}'.format( - start, this_year, FSF), file=out_file) + start, this_year, owner), file=out_file) for line in in_file: out_file.write(line) except UnicodeDecodeError: @@ -38,29 +39,40 @@ def do_file(path): os.chmod(path, permissions) +def remove(dirs, path): + try: + dirs.remove(path) + except ValueError: + pass + + def do_walk(): + try: + owner = sys.argv[1] + except IndexError: + owner = FSF for root, dirs, files in os.walk('.'): if root == '.': - dirs.remove('.bzr') - dirs.remove('bin') - dirs.remove('contrib') - dirs.remove('develop-eggs') - dirs.remove('eggs') - dirs.remove('parts') - files.remove('gnu-COPYING-GPL') - files.remove('.installed.cfg') - files.remove('.bzrignore') - files.remove('distribute_setup.py') + remove(dirs, '.bzr') + remove(dirs, 'bin') + remove(dirs, 'contrib') + remove(dirs, 'develop-eggs') + remove(dirs, 'eggs') + remove(dirs, 'parts') + remove(dirs, 'gnu-COPYING-GPL') + remove(dirs, '.installed.cfg') + remove(dirs, '.bzrignore') + remove(dirs, 'distribute_setup.py') if root == './src': - dirs.remove('mailman.egg-info') + remove(dirs, 'mailman.egg-info') if root == './src/mailman': - dirs.remove('messages') + remove(dirs, 'messages') for file_name in files: if os.path.splitext(file_name)[1] in ('.pyc', '.gz', '.egg'): continue path = os.path.join(root, file_name) if os.path.isfile(path): - do_file(path) + do_file(path, owner) if __name__ == '__main__': |
