aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorumarcor <unai.martinezcorral@ehu.eus>2020-08-27 10:05:11 +0200
committerTristan Gingold <tgingold@free.fr>2020-09-16 07:57:25 +0200
commitbec6b6245851c955fc7e16835af81a4417133e05 (patch)
tree35c838945c01f17c34793fa056ac8a90bc35fc6b /testsuite
parent90a08421ec6756e49e167d712c1290fe029a13a8 (diff)
downloadghdl-bec6b6245851c955fc7e16835af81a4417133e05.tar.gz
ghdl-bec6b6245851c955fc7e16835af81a4417133e05.tar.bz2
ghdl-bec6b6245851c955fc7e16835af81a4417133e05.zip
py: format testsuite/python/units01/show_units.py
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/python/units01/show_units.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/testsuite/python/units01/show_units.py b/testsuite/python/units01/show_units.py
index ad002312f..aad377723 100755
--- a/testsuite/python/units01/show_units.py
+++ b/testsuite/python/units01/show_units.py
@@ -5,18 +5,21 @@ import libghdl.thin.files_map as files_map
import libghdl.thin.vhdl.nodes as nodes
import libghdl.thin.vhdl.sem_lib as sem_lib
+
def init():
"""Initialization: set options and then load libaries"""
- libghdl.set_option(b'--std=08')
+ libghdl.set_option(b"--std=08")
libghdl.analyze_init()
+
def get_identifier_ptr(n):
"""Return the python string from node :param n: identifier"""
- return name_table.Get_Name_Ptr(nodes.Get_Identifier(n)).decode('utf-8')
+ return name_table.Get_Name_Ptr(nodes.Get_Identifier(n)).decode("utf-8")
+
def list_units(filename):
# Load the file
- file_id = name_table.Get_Identifier(filename.encode('utf_8'))
+ file_id = name_table.Get_Identifier(filename.encode("utf_8"))
sfe = files_map.Read_Source_File(name_table.Null_Identifier, file_id)
if sfe == files_map.No_Source_File_Entry:
print("cannot open file '{}'".format(filename))
@@ -30,17 +33,18 @@ def list_units(filename):
while unit != nodes.Null_Iir:
lib_unit = nodes.Get_Library_Unit(unit)
if nodes.Get_Kind(lib_unit) == nodes.Iir_Kind.Entity_Declaration:
- print('entity {}'.format(get_identifier_ptr(lib_unit)))
+ print("entity {}".format(get_identifier_ptr(lib_unit)))
elif nodes.Get_Kind(lib_unit) == nodes.Iir_Kind.Architecture_Body:
- print('architecture {}'.format(get_identifier_ptr(lib_unit)))
+ print("architecture {}".format(get_identifier_ptr(lib_unit)))
else:
- print('unknown unit!')
+ print("unknown unit!")
unit = nodes.Get_Chain(unit)
def main():
init()
- list_units('demo.vhdl')
+ list_units("demo.vhdl")
+
-if __name__ == '__main__':
+if __name__ == "__main__":
main()