Skip to content

Commit 6b555ad

Browse files
committed
Fix parser
1 parent 61da26b commit 6b555ad

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

smpt/ptio/ptnet.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,17 @@ def ids_mapping(self, filename: str) -> None:
327327

328328
for place_node in root.iter(xmlns + 'place'):
329329
place_id = place_node.attrib['id']
330-
place_name = place_node.find(xmlns + 'name/' + xmlns + 'text').text.replace('#', '.').replace(',', '.') # '#' and ',' forbidden in SMT-LIB
331-
self.pnml_places_mapping[place_id] = place_name
330+
place_text = place_node.find(xmlns + 'name/' + xmlns + 'text')
331+
if place_text is not None:
332+
place_name = place_text.text.replace('#', '.').replace(',', '.') # '#' and ',' forbidden in SMT-LIB
333+
self.pnml_places_mapping[place_id] = place_name
332334

333335
for transition_node in root.iter(xmlns + 'transition'):
334336
transition_id = transition_node.attrib['id']
335-
transition_name = transition_node.find(xmlns + 'name/' + xmlns + 'text').text.replace('#', '.').replace(',', '.') # '#' and ',' forbidden in SMT-LIB
336-
self.pnml_transitions_mapping[transition_id] = transition_name
337+
transition_text = transition_node.find(xmlns + 'name/' + xmlns + 'text')
338+
if transition_text is not None:
339+
transition_name = transition_text.text.replace('#', '.').replace(',', '.') # '#' and ',' forbidden in SMT-LIB
340+
self.pnml_transitions_mapping[transition_id] = transition_name
337341

338342
def parse_net(self, filename: str) -> None:
339343
""" Petri net parser.

0 commit comments

Comments
 (0)