From 5de428df07c571322cfbc055a780d41f0ce95a67 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 21 Jun 2022 22:13:10 +0200 Subject: Change encoding to latin-1 for libghdl (to comply with standard). It can be monkey-patched via pyGHDL.libGHDL.ENCODING. (cherry picked from commit 2dd38de9d52493cde7c045ed73a987ed06bf617a) --- pyGHDL/dom/NonStandard.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pyGHDL/dom/NonStandard.py') diff --git a/pyGHDL/dom/NonStandard.py b/pyGHDL/dom/NonStandard.py index 14f5e1eac..1dbef9a9a 100644 --- a/pyGHDL/dom/NonStandard.py +++ b/pyGHDL/dom/NonStandard.py @@ -59,7 +59,7 @@ from pyGHDL.libghdl import ( errorout_memory, LibGHDLException, utils, - files_map_editor, + files_map_editor, ENCODING, ) from pyGHDL.libghdl.flags import Flag_Gather_Comments from pyGHDL.libghdl.vhdl import nodes, sem_lib @@ -155,11 +155,11 @@ class Document(VHDLModel_Document): self.__domTranslateTime = time.perf_counter() - t1 def __loadFromPath(self): - with self._filename.open("r", encoding="utf-8") as file: + with self._filename.open("r", encoding=ENCODING) as file: self.__loadFromString(file.read()) def __loadFromString(self, sourceCode: str): - sourcesBytes = sourceCode.encode("utf-8") + sourcesBytes = sourceCode.encode(ENCODING) sourceLength = len(sourcesBytes) bufferLength = sourceLength + 128 self.__ghdlFileID = name_table.Get_Identifier(str(self._filename)) -- cgit v1.2.3 From baccb0768b6636f8322ff499cb0887dbaa4f7f59 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 21 Jun 2022 22:20:06 +0200 Subject: Code formatting based on black. (cherry picked from commit 1f9773b56a90c6564698c842501f3889714fad84) --- pyGHDL/dom/NonStandard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pyGHDL/dom/NonStandard.py') diff --git a/pyGHDL/dom/NonStandard.py b/pyGHDL/dom/NonStandard.py index 1dbef9a9a..d7a65b4a4 100644 --- a/pyGHDL/dom/NonStandard.py +++ b/pyGHDL/dom/NonStandard.py @@ -59,7 +59,8 @@ from pyGHDL.libghdl import ( errorout_memory, LibGHDLException, utils, - files_map_editor, ENCODING, + files_map_editor, + ENCODING, ) from pyGHDL.libghdl.flags import Flag_Gather_Comments from pyGHDL.libghdl.vhdl import nodes, sem_lib -- cgit v1.2.3 From 08a338e9568c333929c6863be60580619e3e77ff Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 21 Jun 2022 21:52:50 +0200 Subject: Changed '"...".format(...)' to f-strings. (cherry picked from commit 86a5638332b2573523b1f9768cf321a41b16f21c) --- pyGHDL/dom/NonStandard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pyGHDL/dom/NonStandard.py') diff --git a/pyGHDL/dom/NonStandard.py b/pyGHDL/dom/NonStandard.py index d7a65b4a4..db160faaf 100644 --- a/pyGHDL/dom/NonStandard.py +++ b/pyGHDL/dom/NonStandard.py @@ -143,14 +143,14 @@ class Document(VHDLModel_Document): else: self.__loadFromString(sourceCode) - if dontParse == False: + if not dontParse: # Parse input file t1 = time.perf_counter() self.__ghdlFile = sem_lib.Load_File(self.__ghdlSourceFileEntry) CheckForErrors() self.__ghdlProcessingTime = time.perf_counter() - t1 - if dontTranslate == False: + if not dontTranslate: t1 = time.perf_counter() self.translate() self.__domTranslateTime = time.perf_counter() - t1 -- cgit v1.2.3