From c408ee16926118407b355d3428fea03119cf50b9 Mon Sep 17 00:00:00 2001 From: Diorcet Yann Date: Mon, 29 Jan 2024 13:58:24 +0100 Subject: [PATCH 1/2] Fix issues with spaces in path --- PySpice/Scripts/pyspice_post_installation.py | 7 +++++-- PySpice/Spice/Netlist.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PySpice/Scripts/pyspice_post_installation.py b/PySpice/Scripts/pyspice_post_installation.py index d9184b02..415ac700 100644 --- a/PySpice/Scripts/pyspice_post_installation.py +++ b/PySpice/Scripts/pyspice_post_installation.py @@ -31,6 +31,7 @@ import shutil import sys import tempfile +import re import requests @@ -252,8 +253,10 @@ def install_ngspice_dll(self): print(rule) print(content) print(rule) - cm_path = spice64_path.joinpath('lib', 'ngspice') - content = content.replace('../lib/ngspice/', str(cm_path) + '/') + content = re.sub(r'^(\s*codemodel\s*).*[\\\/](.*)$', + lambda x: "{} '{}'".format(x.group(1), spice64_path.joinpath('lib', 'ngspice', x.group(2))), + content, + flags=re.MULTILINE) print(rule) print(content) print(rule) diff --git a/PySpice/Spice/Netlist.py b/PySpice/Spice/Netlist.py index 96fbc733..28696853 100644 --- a/PySpice/Spice/Netlist.py +++ b/PySpice/Spice/Netlist.py @@ -1236,7 +1236,7 @@ def _str_includes(self, simulator=None): path = path_flavour real_paths.append(path) - return join_lines(real_paths, prefix='.include ') + os.linesep + return join_lines([f"'{p}'" for p in real_paths], prefix='.include ') + os.linesep else: return '' From 98989f0ebe0ef1f5c435a4f160d29c0cbc7627eb Mon Sep 17 00:00:00 2001 From: Diorcet Yann Date: Mon, 29 Jan 2024 13:58:44 +0100 Subject: [PATCH 2/2] Fix multiple issues with parsing --- PySpice/Spice/Parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PySpice/Spice/Parser.py b/PySpice/Spice/Parser.py index 3fcfda71..7f71576a 100644 --- a/PySpice/Spice/Parser.py +++ b/PySpice/Spice/Parser.py @@ -498,7 +498,7 @@ def __init__(self, line): i = parameter.position self._dict_parameters[parameter.attribute_name] = self._parameters[i] to_delete.append(i) - for i in to_delete: + for i in sorted(to_delete, reverse=True): del self._parameters[i] # self._logger.debug(os.linesep + self.__repr__()) @@ -890,7 +890,7 @@ def _parse(self, lines, recurse=False, section=None): # first line so they'll parse incorrectly if that line is removed. # For everything else, assume the first line is a TITLE line and # remove it. - if str(lines[0]).startswith(('.model', '.subckt')): + if str(lines[0]).lower().startswith(('.model', '.subckt')): start_index = 0 else: start_index = 1