Skip to content

Commit

Permalink
Merge pull request #911 from brf2cb/support-elist-in-header-comment
Browse files Browse the repository at this point in the history
Add support for elist in mf4 header comment
  • Loading branch information
danielhrisca authored Sep 14, 2023
2 parents 8d79073 + 2dcb6ac commit f4c2039
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/asammdf/blocks/v4_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5477,24 +5477,28 @@ def comment(self, string):
self._common_properties.clear()

def parse_common_properties(root):
root_name = root.get("name")
info = {}
if root.tag in ("list", "tree"):
info[root.get("name")] = {}
if root.tag in ("list", "tree", "elist"):
info[root_name] = {}
try:
for element in root:
name = element.get("name")

if element.tag == "e":
if root.tag == "tree":
info[root.get("name")][name] = element.text or ""
info[root_name][name] = element.text or ""
else:
info[name] = element.text or ""

elif element.tag in ("list", "tree"):
elif element.tag in ("list", "tree", "elist"):
info.update(parse_common_properties(element))

elif element.tag == "li":
info[root.get("name")].update(parse_common_properties(element))
info[root_name].update(parse_common_properties(element))

elif element.tag == "eli":
info[root_name][str(len(info[root_name]))] = element.text or ""
except:
print(format_exc())

Expand Down

0 comments on commit f4c2039

Please sign in to comment.