Skip to content

Commit

Permalink
More sophisticated method of parsing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dalmijn committed Oct 11, 2023
1 parent 4b0d7a7 commit 01432df
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/fiat/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,18 @@ def _parse_meta(
if line.startswith("#"):
t = line.strip().split("=")
if len(t) == 1:
lst = t[0].split(",")
_entry = lst[0].strip().replace("#", "").lower()
_val = [item.strip() for item in lst[1:]]
self.meta[_entry] = _val
tl = t[0].split(":")
if len(tl) > 1:
lst = tl[1].split(",")
_entry = tl[0].strip().replace("#", "").lower()
_val = [item.strip() for item in lst]
self.meta[_entry] = _val
else:
lst = t[0].split(",")
_entry = lst[0].strip().replace("#", "").lower()
_val = [item.strip() for item in lst[1:]]
self.meta[_entry] = _val
# raise ValueError("Supplied metadata in unknown format..")
else:
key, item = t
self.meta[key.strip().replace("#", "").lower()] = item.strip()
Expand Down

0 comments on commit 01432df

Please sign in to comment.