X-Git-Url: http://git.tremily.us/?p=update-copyright.git;a=blobdiff_plain;f=update_copyright.py;h=f4e39dfcbbfe226b43c97679bde290e0306af192;hp=10fed81c017efcaaaa43c1fbf06635ae88c4c530;hb=82deee063ae32d4b12df66e8418c6b21479de6a9;hpb=86da8056fa1df0b2bd1affd24beed2fe92279887
diff --git a/update_copyright.py b/update_copyright.py
index 10fed81..f4e39df 100755
--- a/update_copyright.py
+++ b/update_copyright.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
-# COPYRIGHT
+# Copyright
"""Automatically update copyright boilerplate.
@@ -47,7 +47,7 @@ License along with %(project)s. If not, see
.
""".strip()
-COPY_RIGHT_TAG='-xyz-COPY-RIGHT-zyx-' # unlikely to occur in the wild :p
+COPY_RIGHT_TAG='-xyz-COPY' + '-RIGHT-zyx-' # unlikely to occur in the wild :p
ALIASES = {
'Alberto Gomez-Casado':
@@ -244,12 +244,13 @@ def _tag_copyright(contents):
... (copyright ends)
... bla bla bla
... '''
- >>> print _tag_copyright(contents),
+ >>> print _tag_copyright(contents).replace('COPY-RIGHT', 'CR')
Some file
bla bla
- -xyz-COPY-RIGHT-zyx-
+ -xyz-CR-zyx-
(copyright ends)
bla bla bla
+
"""
lines = []
incopy = False
@@ -291,33 +292,34 @@ def _update_copyright(contents, original_year, authors):
contents = _tag_copyright(contents)
return contents.replace(COPY_RIGHT_TAG, copyright_string)
-def ignored_file(filename, ignored_paths=None, ignored_files=None):
+def ignored_file(filename, ignored_paths=None, ignored_files=None,
+ check_disk=True, check_vcs=True):
"""
>>> ignored_paths = ['./a/', './b/']
>>> ignored_files = ['x', 'y']
- >>> ignored_file('./a/z', ignored_paths, ignored_files)
+ >>> ignored_file('./a/z', ignored_paths, ignored_files, False, False)
True
- >>> ignored_file('./ab/z', ignored_paths, ignored_files)
+ >>> ignored_file('./ab/z', ignored_paths, ignored_files, False, False)
False
- >>> ignored_file('./ab/x', ignored_paths, ignored_files)
+ >>> ignored_file('./ab/x', ignored_paths, ignored_files, False, False)
True
- >>> ignored_file('./ab/xy', ignored_paths, ignored_files)
+ >>> ignored_file('./ab/xy', ignored_paths, ignored_files, False, False)
False
- >>> ignored_file('./z', ignored_paths, ignored_files)
+ >>> ignored_file('./z', ignored_paths, ignored_files, False, False)
False
"""
if ignored_paths == None:
ignored_paths = IGNORED_PATHS
if ignored_files == None:
ignored_files = IGNORED_FILES
- if os.path.isfile(filename) == False:
+ if check_disk == True and os.path.isfile(filename) == False:
return True
for path in ignored_paths:
if filename.startswith(path):
return True
if os.path.basename(filename) in ignored_files:
return True
- if is_versioned(filename) == False:
+ if check_vcs == True and is_versioned(filename) == False:
return True
return False