Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoireLamb authored and apacha committed Jun 11, 2024
1 parent 33262ba commit 26b920a
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions mung/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,10 @@ def read_nodes_from_file(filename: str) -> List[Node]:
root = tree.getroot()
logging.debug('XML parsed.')
nodes = []
dataset = 'Unknown'

if 'dataset' in root.attrib:
dataset = root.attrib['dataset']
document = 'Unknown'

if 'document' in root.attrib:
document = root.attrib['document']
node_tag = 'Node'

if not list(root.iter(node_tag)):
node_tag = 'CropObject'
dataset = root.attrib.get('dataset', 'Unknown')
document = root.attrib.get('document', 'Unknown')
node_tag = 'Node' if list(root.iter('Node')) else 'CropObject'

for i, node in enumerate(root.iter(node_tag)):
######################################################
Expand Down

0 comments on commit 26b920a

Please sign in to comment.