From 7ae041cf6a998210ce4773470732410e35c1df8e Mon Sep 17 00:00:00 2001 From: Milosz Wasilewski Date: Mon, 7 Nov 2016 11:10:06 +0000 Subject: validate.py: fix pep8 issues Change-Id: I8df280349720e93b9d8bdeac90dc2fde20de2a8a Signed-off-by: Milosz Wasilewski --- validate.py | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'validate.py') diff --git a/validate.py b/validate.py index faae744..94d394e 100755 --- a/validate.py +++ b/validate.py @@ -58,12 +58,13 @@ def pep8_check(filepath, ignore_options=None): print_stderr(message) return 0 + def metadata_check(filepath): if filepath.lower().endswith("yaml"): with open(filepath, "r") as f: result_message_list = [] y = yaml.load(f.read()) - if not 'metadata' in y.keys(): + if 'metadata' not in y.keys(): result_message_list.append("* METADATA [FAILED]: " + filepath) result_message_list.append("\tmetadata section missing") publish_result(result_message_list) @@ -78,10 +79,10 @@ def metadata_check(filepath): 'devices']) if not mandatory_keys.issubset(set(metadata_dict.keys())): result_message_list.append("* METADATA [FAILED]: " + filepath) - result_message_list.append("\tmandatory keys missing: %s" % \ - mandatory_keys.difference(set(metadata_dict.keys()))) - result_message_list.append("\tactual keys present: %s" % \ - metadata_dict.keys()) + result_message_list.append("\tmandatory keys missing: %s" % + mandatory_keys.difference(set(metadata_dict.keys()))) + result_message_list.append("\tactual keys present: %s" % + metadata_dict.keys()) publish_result(result_message_list) return 1 for key in mandatory_keys: @@ -94,6 +95,7 @@ def metadata_check(filepath): publish_result(result_message_list) return 0 + def validate_yaml(filename): with open(filename, "r") as f: try: @@ -192,28 +194,28 @@ def main(args): if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("-p", - "--pep8-ignore", - nargs="*", - default="E501", - help="Space separated list of pep8 exclusions", - dest="pep8_ignore") + "--pep8-ignore", + nargs="*", + default="E501", + help="Space separated list of pep8 exclusions", + dest="pep8_ignore") parser.add_argument("-s", - "--shellcheck-ignore", - nargs="*", - help="Space separated list of shellcheck exclusions", - dest="shellcheck_ignore") + "--shellcheck-ignore", + nargs="*", + help="Space separated list of shellcheck exclusions", + dest="shellcheck_ignore") parser.add_argument("-g", - "--git-latest", - action="store_true", - default=False, - help="If set, the script will try to evaluate files in last git \ - commit instead of the whole repository", - dest="git_latest") + "--git-latest", + action="store_true", + default=False, + help="If set, the script will try to evaluate files in last git \ + commit instead of the whole repository", + dest="git_latest") parser.add_argument("-f", - "--file-path", - default="", - help="Path to the file that should be checked", - dest="file_path") + "--file-path", + default="", + help="Path to the file that should be checked", + dest="file_path") args = parser.parse_args() main(args) -- cgit v1.2.3