Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix Parser.py] fixed up the class Parser can not parser subckt by a mistake, #361

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PySpice/Spice/NgSpice/Shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 10 additions & 5 deletions PySpice/Spice/Parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('"')

##############################################

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down