aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-11-16 22:15:51 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-11-16 22:15:51 +0000
commitcf63bff8cd66b2c1640092d4f067b3073e53c4b7 (patch)
tree73a1033d56a17171d334796393ecf1c8831b9180 /scripts
parent994e65e5a80c814c2ffe6da66a356228e37f35f4 (diff)
downloadYAGE-cf63bff8cd66b2c1640092d4f067b3073e53c4b7.tar.gz
YAGE-cf63bff8cd66b2c1640092d4f067b3073e53c4b7.zip
Fixed header script
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/add_version_headers21
1 files changed, 13 insertions, 8 deletions
diff --git a/scripts/add_version_headers b/scripts/add_version_headers
index dad385e7..209f0c66 100755
--- a/scripts/add_version_headers
+++ b/scripts/add_version_headers
@@ -37,11 +37,13 @@ header = """/* ---------------------------------------------------------------\
"""
-lic_regex = re.compile("\/\* -+\n \* ([a-z]+\.(?:cpp|h)|\{0\})\n(?: \*[ a-zA-Z0-9_.,\-()<>@]*\n)+ \* -+\n \*/", re.MULTILINE)
+lic_regex = re.compile(
+ "\/\* -+\n \* ([a-z]+\.(?:cpp|h)|\{0\})\n(?: \*[ a-zA-Z0-9_.,\-()<>@]*\n)+ \* -+\n \*/", re.MULTILINE)
class HeaderUpdate(object):
"""Updates the header in all the source and header files in the code"""
+
def __init__(self, **kwargs):
self.match_re = ".*[.]cpp$|.*[.]h$"
self.exclude_re = "^$"
@@ -70,11 +72,14 @@ class HeaderUpdate(object):
src = f.read()
f.seek(0)
if lic_regex.match(src):
- print("Updating {}: ".format(os.path.basename(filePath)), end="")
- src = lic_regex.sub(header.format(os.path.basename(filePath)), src)
+ print("Updating {}: ".format(
+ os.path.basename(filePath)), end="")
+ src = lic_regex.sub(header.format(
+ os.path.basename(filePath)), src)
print("done")
else:
- print("Adding {}: ".format(os.path.basename(filePath)), end="")
+ print("Adding {}: ".format(
+ os.path.basename(filePath)), end="")
src = header.format(os.path.basename(filePath)) + src
print("done")
f.write(src)
@@ -87,11 +92,11 @@ class HeaderUpdate(object):
def _traverseDir(self, path, fileOperation):
for subdir, dirs, files in os.walk(os.getcwd()):
- if (re.match(self.match_dir, subdir)) and \
- (not re.match(self.exclude_dir, subdir)):
+ if (re.match(self.match_dir, subdir)) and (
+ not re.match(self.exclude_dir, subdir)):
for fileName in files:
- if (re.match(self.match_re, fileName)) and \
- (not re.match(self.exclude_re, fileName)):
+ if (re.match(self.match_re, fileName)) and (
+ not re.match(self.exclude_re, fileName)):
fileOperation(os.path.join(subdir, fileName))