aboutsummaryrefslogtreecommitdiff
path: root/util/licensecheck.py
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-02-01 17:18:08 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-02-01 17:18:08 +0100
commite6cc0a2b756f1462bcce2222437a6e159be48498 (patch)
tree2bab92eb8777a0f531fe42309f388330916987f1 /util/licensecheck.py
parentCleaned up UrlLineEdit (diff)
downloadsmolbote-e6cc0a2b756f1462bcce2222437a6e159be48498.tar.xz
Updated license script
Added missing license headers Added pre-commit hook to check for missing licenses
Diffstat (limited to 'util/licensecheck.py')
-rwxr-xr-xutil/licensecheck.py59
1 files changed, 0 insertions, 59 deletions
diff --git a/util/licensecheck.py b/util/licensecheck.py
deleted file mode 100755
index be6de9a..0000000
--- a/util/licensecheck.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python3
-
-# TODO: username argument
-# TODO: updating licenses
-
-import argparse
-import datetime
-
-def getLicense(licenseFile):
- with open(licenseFile) as rawlicense:
- licensetext = rawlicense.read()
-
- # fill in name and year
- licensetext = licensetext.replace('$AUTHOR$', 'Xian Nox')
- licensetext = licensetext.replace('$CURRENTYEAR$', str(datetime.datetime.now().year))
-
- return licensetext
-
-def hasLicense(sourceFile):
- with open(sourceFile) as source:
- if source.readline().startswith('/** LICENSE **'):
- return True
- else:
- return False
-
-def fix(sourceFile, licenseText):
- with open(sourceFile, 'r') as source:
- origData = source.read()
- with open(sourceFile, 'w') as source:
- source.write(licenseText + origData)
-
-def main(license, src, verbose=False):
- if verbose is True:
- print("Using license header {0}".format(license))
- print("Going through {0}".format(src))
-
- # read license file
- licensetext = getLicense(license)
- #print(licensetext)
-
- # open source file and check for license
- for filename in src:
- if hasLicense(filename):
- print("{0} has license".format(filename))
- else:
- fix(filename, licensetext)
- print("{0} license added".format(filename))
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(description='Check source files for license')
- parser.add_argument('-l', '--license', required=True)
- parser.add_argument('-v', '--verbose', action='store_true')
- parser.add_argument('src', nargs='*')
- args = parser.parse_args()
-
- main(args.license, args.src, args.verbose)
-else:
- print('Do not use this as an import!')
- sys.exit(-1)