diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-11-16 22:01:32 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-11-16 22:01:32 +0000 |
commit | 994e65e5a80c814c2ffe6da66a356228e37f35f4 (patch) | |
tree | bc1b09ff6781df3f2bd0cd6ee7c23b8668e5ce86 /scripts | |
parent | 714ed292b37a0d9baee69186bca38cf0f0c77c89 (diff) | |
download | YAGE-994e65e5a80c814c2ffe6da66a356228e37f35f4.tar.gz YAGE-994e65e5a80c814c2ffe6da66a356228e37f35f4.zip |
Fixing license headers
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/add_version_headers | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/scripts/add_version_headers b/scripts/add_version_headers index 2d653675..dad385e7 100755 --- a/scripts/add_version_headers +++ b/scripts/add_version_headers @@ -37,14 +37,13 @@ header = """/* ---------------------------------------------------------------\ """ -lic_regex = re.compile("\/\* -+\n \* [a-z]+\.cpp\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$|.*[.]hpp$" + self.match_re = ".*[.]cpp$|.*[.]h$" self.exclude_re = "^$" self.exclude_build = True self.exclude_dir = ".*build.*" @@ -70,9 +69,14 @@ class HeaderUpdate(object): with open(filePath, "r+") as f: src = f.read() f.seek(0) - print("Updating {}:".format(os.path.basename(filePath)), end="") - lic_regex.sub(header.format(os.path.basename(filePath)), src) - print("done") + 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("done") + else: + print("Adding {}: ".format(os.path.basename(filePath)), end="") + src = header.format(os.path.basename(filePath)) + src + print("done") f.write(src) f.truncate() |