From d3fa1e2f6795903daddbf31f5c8e5d55f21ed992 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sat, 16 Nov 2024 10:08:37 +0100 Subject: [PATCH 1/3] FIX: read Spice model from file --- src/pyedb/dotnet/edb_core/cell/hierarchy/component.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pyedb/dotnet/edb_core/cell/hierarchy/component.py b/src/pyedb/dotnet/edb_core/cell/hierarchy/component.py index 95517f6f9f..b2ba1a854a 100644 --- a/src/pyedb/dotnet/edb_core/cell/hierarchy/component.py +++ b/src/pyedb/dotnet/edb_core/cell/hierarchy/component.py @@ -20,6 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +from charset_normalizer import detect import logging import re from typing import Optional @@ -845,7 +846,11 @@ def assign_spice_model( if not name: name = get_filename_without_extension(file_path) - with open(file_path, "r") as f: + with open(file_path, 'rb') as file: + raw_data = file.read() + detected_encoding = detect(raw_data)['encoding'] + + with open(file_path, "r", encoding=detected_encoding) as f: for line in f: if "subckt" in line.lower(): pin_names_sp = [i.strip() for i in re.split(" |\t", line) if i] From f082cecc20ec59737aa20e4a5a7e675a9d9747ce Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:45:42 +0000 Subject: [PATCH 2/3] MISC: Auto fixes from pre-commit.com hooks For more information, see https://pre-commit.ci --- src/pyedb/dotnet/edb_core/cell/hierarchy/component.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pyedb/dotnet/edb_core/cell/hierarchy/component.py b/src/pyedb/dotnet/edb_core/cell/hierarchy/component.py index b2ba1a854a..e51c372a62 100644 --- a/src/pyedb/dotnet/edb_core/cell/hierarchy/component.py +++ b/src/pyedb/dotnet/edb_core/cell/hierarchy/component.py @@ -20,12 +20,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from charset_normalizer import detect import logging import re from typing import Optional import warnings +from charset_normalizer import detect + from pyedb.dotnet.edb_core.cell.hierarchy.hierarchy_obj import Group from pyedb.dotnet.edb_core.cell.hierarchy.model import PinPairModel, SPICEModel from pyedb.dotnet.edb_core.cell.hierarchy.netlist_model import NetlistModel @@ -846,9 +847,9 @@ def assign_spice_model( if not name: name = get_filename_without_extension(file_path) - with open(file_path, 'rb') as file: + with open(file_path, "rb") as file: raw_data = file.read() - detected_encoding = detect(raw_data)['encoding'] + detected_encoding = detect(raw_data)["encoding"] with open(file_path, "r", encoding=detected_encoding) as f: for line in f: From b743d172208b7a7eda051baad046bfb1f8bcdbe2 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Sat, 16 Nov 2024 11:43:45 +0100 Subject: [PATCH 3/3] add dependency charset_normalizer --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 64855bfcba..02fd98b8c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,8 @@ dependencies = [ "pydantic>=2.6.4,<2.10", "Rtree >= 1.2.0", "toml == 0.10.2", - "scikit-rf" + "scikit-rf", + "charset_normalizer" ] [project.optional-dependencies]