diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-08-02 09:53:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-02 09:53:13 +0100 |
commit | 30461c89fd53e14bb9f5a83eaf6d72040931b62a (patch) | |
tree | 3303e22526d346030fa78dabcebdcfd0a3f11f1f /scripts/add_version_headers | |
parent | a1fc39d49e442fcc756091ee028ff33bdd9c518a (diff) | |
parent | 489c3550c3694ffc5f67c1527a3f021a01c8bbfc (diff) | |
download | YAGE-30461c89fd53e14bb9f5a83eaf6d72040931b62a.tar.gz YAGE-30461c89fd53e14bb9f5a83eaf6d72040931b62a.zip |
Merge pull request #2 from ymherklotz/develop
Merging
Diffstat (limited to 'scripts/add_version_headers')
-rwxr-xr-x | scripts/add_version_headers | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/add_version_headers b/scripts/add_version_headers new file mode 100755 index 00000000..5de82a6c --- /dev/null +++ b/scripts/add_version_headers @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# ----------------------------------------------------------------------------- +# add_version_headers +# +# Add version header +# +# Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License +# See file LICENSE for more details +# ----------------------------------------------------------------------------- + +"""\file add_version_headers +\brief Adds the version headers to every file. + +Add Version Headers +=================== + +This file adds the version headers to every file in the directory + + +Improvements +------------ + +Add the ability to input command line arguments. +""" + +import os +import re +import sys + + +header = """/* ---------------------------------------------------------------\ +------------- + * {0} + * + * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License + * See file LICENSE for more details + * ---------------------------------------------------------------------------- + */ + +""" + + +def main(argv): + for subdir, dirs, files in os.walk(os.getcwd()): + if not re.match(".*build.*", subdir): + for file_ in files: + if re.match(".*[.]cpp$|.*[.]hpp$", file_) and not re.match("^picopng[.]cpp$", file_): + print(os.path.join(subdir, file_), end=" ") + with open(os.path.join(subdir, file_), 'r') as src_file: + src = src_file.read() + with open(os.path.join(subdir, file_), 'w') as src_file_lic: + src_file_lic.write(header.format(file_)) + src_file_lic.write(src) + print("-- done") + + +if __name__ == "__main__": + main(sys.argv) |