[Zope-Checkins] CVS: Zope3/utilities - license_check.py:1.1.2.2
Janko Hauser
jh@comunit.de
Mon, 1 Apr 2002 07:36:25 -0500
Update of /cvs-repository/Zope3/utilities
In directory cvs.zope.org:/tmp/cvs-serv25344
Modified Files:
Tag: Zope-3x-branch
license_check.py
Log Message:
Documented option --include_init
=== Zope3/utilities/license_check.py 1.1.2.1 => 1.1.2.2 ===
--nobackup : Do not generate backup files
+--include_init : Process also the __init__.py files
--undo : Rename the backup files to the original files, mainly for
testing.
path : If not given start in the current directory.
+
+Example: To put a license in all files
+license_check.py -c -v -s --nobackup --include_init
"""
@@ -137,11 +141,14 @@
if lines and re.match('#!', lines[0]):
start=1
lines.insert(start, self.license)
+ # keep the current stat_mod
+ fmode = os.stat(self.fname)[0]
# There can already be a backup file from the removal pass
- if self.backup and not os.path.isfile(self.fname+'.changed'):
- os.rename(self.fname, self.fname+'.changed')
+ if self.backup and not os.path.isfile(self.fname+'.no_license'):
+ os.rename(self.fname, self.fname+'.no_license')
open(self.fname, 'w').write(''.join(lines))
- if self.verbose:
+ os.chmod(self.fname, fmode)
+ if self.verbose:
print 'License included: %s' % self.fname
return
@@ -191,7 +198,7 @@
# keep the current stat_mod
fmode = os.stat(self.fname)[0]
if self.backup:
- os.rename(self.fname, self.fname+'.changed')
+ os.rename(self.fname, self.fname+'.no_license')
if self.verbose:
print 'License removed: %s' % self.fname
open(self.fname,'w').write(''.join(save))
@@ -213,8 +220,9 @@
self.include_init = 0
self.license_path='./'
- for key,value in kws:
- setattr(self, key, value)
+ if kws:
+ for key,value in kws:
+ setattr(self, key, value)
return
@@ -259,14 +267,16 @@
def run(self):
if self.conf.undo:
- for fname in GlobDirectoryWalker(self.conf.path,"*.changed"):
+ for fname in GlobDirectoryWalker(self.conf.path,"*.no_license"):
old_name = os.path.splitext(fname)[0]
os.rename(fname, old_name)
else:
for fname in GlobDirectoryWalker(".", "*.py"):
if (os.path.split(fname)[-1] == '__init__.py') and \
not self.conf.include_init:
- pass
+ if self.conf.verbose:
+ print 'Skipping: %s' % fname
+ continue
hc = HeaderCheck(fname, self.zpl,
verbose=self.conf.verbose,