diff --git a/PySpice/Spice/NgSpice/Shared.py b/PySpice/Spice/NgSpice/Shared.py index 183c08a4..e99a65c6 100644 --- a/PySpice/Spice/NgSpice/Shared.py +++ b/PySpice/Spice/NgSpice/Shared.py @@ -618,7 +618,7 @@ def _send_char(message_c, ngspice_id, user_data): prefix, _, content = message.partition(' ') if prefix == 'stderr': self._stderr.append(content) - if content.startswith('Warning:'): + if content.startswith('Warning:') or content.startswith('Note:') or content.startswith('Trying gmin'): func = self._logger.warning # elif content.startswith('Warning:'): else: @@ -847,7 +847,7 @@ def exec_command(self, command, join_lines=True): if rc: # Fixme: when not 0 ??? raise NameError("ngSpice_Command '{}' returned {}".format(command, rc)) - if self._error_in_stdout or self._error_in_stderr: + if self._error_in_stdout or self._error_in_stderr: #when run _error_in_stderr have been set raise NgSpiceCommandError("Command '{}' failed".format(command)) if join_lines: diff --git a/PySpice/Spice/Parser.py b/PySpice/Spice/Parser.py index 3fcfda71..6b0bd5f9 100644 --- a/PySpice/Spice/Parser.py +++ b/PySpice/Spice/Parser.py @@ -263,9 +263,13 @@ class Include(Statement): ############################################## def __init__(self, line): + if str(line).lower().startswith('.include'): + super().__init__(line, statement='include') + self._include = self._line.right_of('.include').strip('"') + else: + super().__init__(line, statement='inc') + self._include = self._line.right_of('.inc').strip('"') - super().__init__(line, statement='include') - self._include = self._line.right_of('.include').strip('"') ############################################## @@ -821,6 +825,7 @@ def __init__(self, path=None, source=None, end_of_line_comment=('$', '//', ';'), # Fixme: empty source self._path = path # For use by _parse() when recursing through files. + os.chdir(os.path.dirname(self._path)) if path is not None: with open(str(path), 'r') as f: @@ -927,12 +932,12 @@ def _parse(self, lines, recurse=False, section=None): elif lower_case_text.startswith('model'): model = Model(line) scope.append(model) - elif lower_case_text.startswith('include'): + elif lower_case_text.startswith('include') or lower_case_text.startswith('inc'): incl = Include(line) scope.append(incl) if recurse: from .Library import SpiceLibrary - incl_path = os.path.join(str(self._path.directory_part()), str(incl)) + incl_path = os.path.join(str(os.path.dirname(self._path)), str(incl)) self.incl_libs.append(SpiceLibrary(root_path=incl_path, recurse=recurse)) elif lower_case_text.startswith('lib'): lib = Lib(line) @@ -1005,7 +1010,7 @@ def _build_circuit(circuit, statements, ground): statement.build(circuit, ground) elif isinstance(statement, Model): statement.build(circuit) - elif isinstance(statement, SubCircuit): + elif isinstance(statement, SubCircuitStatement): subcircuit = statement.build(ground) # Fixme: ok ??? circuit.subcircuit(subcircuit)