From 51e9764f04da876993a80f6f09910e019eb84446 Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 22 Jun 2021 12:26:43 +0200 Subject: fix issues reported by Codacy --- scripts/pnodespy.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/pnodespy.py b/scripts/pnodespy.py index b4209bc90..1f95cac4d 100755 --- a/scripts/pnodespy.py +++ b/scripts/pnodespy.py @@ -30,18 +30,27 @@ def print_enum(name, vals): print(" {0} = {1}".format(k, n)) -def print_file_header(): +def print_file_header(includeIntEnumunique=True,includeBindToLibGHDL=True): print(dedent("""\ # Auto generated Python source file from Ada sources # Call 'make' in 'src/vhdl' to regenerate: # - from enum import IntEnum, unique - from pydecor import export - - from pyGHDL.libghdl._decorator import BindToLibGHDL """), end='' ) + if includeIntEnumunique: + print("from enum import IntEnum, unique") + + print("from pydecor import export") + + if includeBindToLibGHDL: + print(dedent("""\ + + from pyGHDL.libghdl._decorator import BindToLibGHDL + + """), end='' + ) + def do_class_kinds(): print_enum(pnodes.prefix_name.rstrip("_"), pnodes.kinds) @@ -97,7 +106,7 @@ def do_iirs_subprg(): def do_libghdl_elocations(): classname = "vhdl__elocations" - print_file_header() + print_file_header(includeIntEnumunique=False, includeBindToLibGHDL=False) print("from pyGHDL.libghdl import libghdl") print() for k in pnodes.funcs: @@ -147,7 +156,7 @@ def do_class_fields(): def read_enum(filename, type_name, prefix, class_name, g=lambda m: m.group(1)): - """Read an enumeration declaration from :param filename:""" + """Read an enumeration declaration from :param filename:.""" pat_decl = re.compile(r" type {0} is$".format(type_name)) pat_enum = re.compile(r" {0}(\w+),?( *-- .*)?$".format(prefix)) pat_comment = re.compile(r" *-- .*$") @@ -183,7 +192,7 @@ def read_enum(filename, type_name, prefix, class_name, g=lambda m: m.group(1)): def read_spec_enum(type_name, prefix, class_name): - """Read an enumeration declaration from iirs.ads""" + """Read an enumeration declaration from iirs.ads.""" read_enum(pnodes.kind_file, type_name, prefix, class_name) @@ -335,7 +344,7 @@ def do_libghdl_names(): val_max = max(val_max, val) dict[name_def] = val res.append((name_def, val)) - print_file_header() + print_file_header(includeBindToLibGHDL=False) print(dedent(""" @export @@ -358,10 +367,6 @@ def do_libghdl_tokens(): def do_libghdl_errorout(): print_file_header() print(dedent("""\ - from enum import IntEnum, unique - - from pyGHDL.libghdl import libghdl - @export @BindToLibGHDL("errorout__enable_warning") def Enable_Warning(Id: int, Enable: bool) -> None: -- cgit v1.2.3