aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorumarcor <unai.martinezcorral@ehu.eus>2021-06-22 12:26:43 +0200
committerumarcor <unai.martinezcorral@ehu.eus>2021-06-22 18:51:02 +0200
commit51e9764f04da876993a80f6f09910e019eb84446 (patch)
treee58928ecfbafb74bf33e8873423e7ed5874422c2 /scripts
parent25a3580831170f8a0acd0a79aca2c94ea4652338 (diff)
downloadghdl-51e9764f04da876993a80f6f09910e019eb84446.tar.gz
ghdl-51e9764f04da876993a80f6f09910e019eb84446.tar.bz2
ghdl-51e9764f04da876993a80f6f09910e019eb84446.zip
fix issues reported by Codacy
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/pnodespy.py31
1 files changed, 18 insertions, 13 deletions
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: