aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-22 19:04:55 +0200
committerGitHub <noreply@github.com>2021-06-22 19:04:55 +0200
commit983236ac3dfd0c455a0ac910a9a468ea2c81e5d9 (patch)
tree2cc031d1ee5e38edc4897691a3d7029b7125c4aa /scripts
parentbcd26f428e704eef5ef665bea7448f3990b5e010 (diff)
parent79d7e4f88b5ea170386628e3d2d00a1bd9634154 (diff)
downloadghdl-983236ac3dfd0c455a0ac910a9a468ea2c81e5d9.tar.gz
ghdl-983236ac3dfd0c455a0ac910a9a468ea2c81e5d9.tar.bz2
ghdl-983236ac3dfd0c455a0ac910a9a468ea2c81e5d9.zip
Fix Codacy issues
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/pnodespy.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/scripts/pnodespy.py b/scripts/pnodespy.py
index dabe94446..f443d36c5 100755
--- a/scripts/pnodespy.py
+++ b/scripts/pnodespy.py
@@ -30,16 +30,15 @@ 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=''
+ """) + "{sysImports}from pydecor import export\n{moduleImports}".format(
+ sysImports = "from enum import IntEnum, unique\n" if includeIntEnumUnique else "",
+ moduleImports = "\nfrom pyGHDL.libghdl._decorator import BindToLibGHDL\n" if includeBindToLibGHDL else "",
+ )
)
@@ -97,7 +96,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 +146,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 +182,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 +334,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 +357,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: