scripts: python: cleanup script and fix PEP8 issues

Ran scripts through flake8 and fixed issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2017-12-12 08:19:25 -05:00 committed by Anas Nashif
commit 7256553955
14 changed files with 346 additions and 228 deletions

View file

@ -20,17 +20,20 @@ __syscall\s+ # __syscall attribute, must be first
typename_regex = re.compile(r'(.*?)([A-Za-z0-9_]+)$')
class SyscallParseException(Exception):
pass
def typename_split(item):
if "[" in item:
raise SyscallParseException("Please pass arrays to syscalls as pointers, unable to process '%s'"
% item)
raise SyscallParseException(
"Please pass arrays to syscalls as pointers, unable to process '%s'" %
item)
if "(" in item:
raise SyscallParseException("Please use typedefs for function pointers")
raise SyscallParseException(
"Please use typedefs for function pointers")
mo = typename_regex.match(item)
if not mo:
@ -115,17 +118,21 @@ def analyze_headers(base_path):
return ret
def parse_args():
global args
parser = argparse.ArgumentParser(description = __doc__,
formatter_class = argparse.RawDescriptionHelpFormatter)
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("-i", "--include", required=True,
help="Base include directory")
parser.add_argument("-j", "--json-file", required=True,
help="Write system call prototype information as json to file")
help="Base include directory")
parser.add_argument(
"-j", "--json-file", required=True,
help="Write system call prototype information as json to file")
args = parser.parse_args()
def main():
parse_args()
@ -152,5 +159,6 @@ def main():
with open(path, 'w') as fp:
fp.write(new)
if __name__ == "__main__":
main()