diff options
author | Stevan Radakovic <stevan.radakovic@linaro.org> | 2012-08-21 12:19:25 +0200 |
---|---|---|
committer | Stevan Radakovic <stevan.radakovic@linaro.org> | 2012-08-21 12:19:25 +0200 |
commit | d19685ee691ccdfd4930eabaf17220f356a0b8ba (patch) | |
tree | 15b2ea1d5fed1b1568aba6652f36b066bbe9563f /scripts | |
parent | 3869e35dc8f1a088626dd6269332101c270db460 (diff) | |
parent | 9c1a3f18060bdd02df40520d5949bd1364fc3956 (diff) |
Add validation script to discover non protected dirs.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/validation.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/validation.py b/scripts/validation.py new file mode 100755 index 0000000..7a544b4 --- /dev/null +++ b/scripts/validation.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# Print the list of build directories with no license protection. + +import sys +import os + + +class Validation(): + + LICENSE_FILE_LIST = [ + "EULA.txt", + "OPEN-EULA.txt", + "BUILD-INFO.txt", + ] + + def __init__(self): + pass + + @classmethod + def find_non_protected_dirs(cls, rootdir): + + non_handled_dirs = [] + + for root, subFolders, files in os.walk(rootdir): + + for dir in subFolders: + dir_path = os.path.join(root, dir) + has_build = False + for fname in os.listdir(dir_path): + if os.path.isfile(os.path.join(dir_path, fname)): + if "gz" in os.path.splitext(fname)[1] or \ + "bz2" in os.path.splitext(fname)[1]: + has_build = True + break + if has_build: + if not cls.has_license_handling(dir_path): + non_handled_dirs.append(dir_path) + + return non_handled_dirs + + @classmethod + def has_license_handling(cls, dir_path): + for fname in os.listdir(dir_path): + if os.path.isfile(os.path.join(dir_path, fname)): + for mode in cls.LICENSE_FILE_LIST: + if mode in fname: + return True + return False + +if __name__ == '__main__': + + result_dirs = Validation.find_non_protected_dirs(sys.argv[1]) + for dir in result_dirs: + print dir |