[Checkins] SVN: zope.repositorypolicy/trunk/src/zope/repositorypolicy/copyright.py - convert relative path to absolute path for working directory

Jens Vagelpohl jens at dataflake.org
Wed Mar 17 09:19:01 EDT 2010


Log message for revision 110023:
  - convert relative path to absolute path for working directory
  - decrease output verbosity by only printing those paths that are 
    being fixed. That means after the first run there is no output
    as indication that there is nothing left to fix.
  

Changed:
  U   zope.repositorypolicy/trunk/src/zope/repositorypolicy/copyright.py

-=-
Modified: zope.repositorypolicy/trunk/src/zope/repositorypolicy/copyright.py
===================================================================
--- zope.repositorypolicy/trunk/src/zope/repositorypolicy/copyright.py	2010-03-17 13:17:14 UTC (rev 110022)
+++ zope.repositorypolicy/trunk/src/zope/repositorypolicy/copyright.py	2010-03-17 13:19:01 UTC (rev 110023)
@@ -13,7 +13,7 @@
     owner = zope.repositorypolicy.project.Checker.copyright_holder
 
     def __init__(self, working_dir):
-        self.working_dir = working_dir
+        self.working_dir = os.path.abspath(working_dir)
 
     def run(self):
         zope.repositorypolicy.project.walk_project_dir(
@@ -29,17 +29,23 @@
         copyright.close()
 
     def _fix_file(self, path):
-        print path
+        needs_fixing = False
         output = StringIO.StringIO()
         for line in open(path):
             m = zope.repositorypolicy.project.COPYRIGHT_PATTERN.match(line)
             if m is not None:
-                line = '%sCopyright (c) %s %s%s' % (
+                new_line = '%sCopyright (c) %s %s%s' % (
                     m.group('lead'), m.group('periods'), self.owner,
                     m.group('tail'))
+                if new_line != line:
+                    line = new_line
+                    needs_fixing = True
             output.write(line)
-        open(path, 'w').write(output.getvalue())
 
+        if needs_fixing:
+            print 'Fixing: %s' % path
+            open(path, 'w').write(output.getvalue())
 
+
 def main():
     FixCopyrightHeaders(sys.argv[1]).run()



More information about the checkins mailing list