Skip to content

Commit 8ea631e

Browse files
committed
Fix bug on metadata XML parsing.
This fixes an issue that caused the metadata to be empty as the code was checking if truthy of Element (XML nodes). But those are false if they have no children.
1 parent d20ddb5 commit 8ea631e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mg_toolkit/metadata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ def get_metadata(self, sample_accession):
7272

7373
# optional
7474
units = sample_attribute.find("UNITS")
75-
if not tag:
75+
if tag is None:
7676
# broken metadata but not fatal
7777
continue
7878

7979
key = tag.text.strip()
8080
key_value = None
81-
key_value = value.text.strip() if value and value.text else ""
82-
if units and units.text:
81+
key_value = value.text.strip() if value is not None and value.text else ""
82+
if units is not None and units.text:
8383
key_value += units.text.strip()
8484

8585
return_meta[key] = key_value

0 commit comments

Comments
 (0)