------------------------------------------------------------
revno: 19
committer: Barry Warsaw <[EMAIL PROTECTED]>
branch nick: admin
timestamp: Thu 2008-02-07 23:06:20 -0500
message:
  A copyright year tweaker.
added:
  bin/copyrights.py

=== added file 'bin/copyrights.py'
--- a/bin/copyrights.py 1970-01-01 00:00:00 +0000
+++ b/bin/copyrights.py 2008-02-08 04:06:20 +0000
@@ -0,0 +1,63 @@
+#! /usr/bin/env python
+#
+# Copyright (C) 2008 by the Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+"""Update the copyright years for all Python files."""
+
+import os
+import re
+import sys
+import datetime
+
+cre = re.compile(r'Copyright \(C\) (?P<start>\d{4})')
+
+
+
+def main():
+    this_year = datetime.datetime.now().year
+    for dirpath, dirnames, filenames in os.walk(sys.argv[1]):
+        for filename in filenames:
+            if not filename.endswith('.py'):
+                continue
+            path = os.path.join(dirpath, filename)
+            print 'Looking at:', path
+            bak = path + '.bak'
+            infp = open(path)
+            outfp = open(bak, 'w')
+            try:
+                for line in infp:
+                    mo = cre.search(line)
+                    if mo:
+                        start = int(mo.group('start'))
+                        if start == this_year:
+                            outfp.write(line)
+                        else:
+                            print >> outfp, ('# Copyright (C) %s-%s by the '
+                                             'Free Software Foundation, Inc.'
+                                             % (start, this_year))
+                    else:
+                        outfp.write(line)
+            finally:
+                infp.close()
+                outfp.close()
+            os.rename(bak, path)
+
+
+
+if __name__ == '__main__':
+    main()



--

https://code.launchpad.net/~mailman-administrivia/mailman-administrivia/admin

You are receiving this branch notification because you are subscribed to it.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to