MCPcopy Index your code
hub / github.com/tensorlayer/TensorLayer / _recursive_parse_xml_to_dict

Function _recursive_parse_xml_to_dict

tensorlayer/files/utils.py:1435–1460  ·  view source on GitHub ↗

Recursively parses XML contents to python dict. We assume that `object` tags are the only ones that can appear multiple times at the same level of a tree. Args: xml: xml tree obtained by parsing XML file contents using lxml.etree Returns: Py

(xml)

Source from the content-addressed store, hash-verified

1433 path = os.path.join(path, 'VOC')
1434
1435 def _recursive_parse_xml_to_dict(xml):
1436 """Recursively parses XML contents to python dict.
1437
1438 We assume that `object` tags are the only ones that can appear
1439 multiple times at the same level of a tree.
1440
1441 Args:
1442 xml: xml tree obtained by parsing XML file contents using lxml.etree
1443
1444 Returns:
1445 Python dictionary holding XML contents.
1446
1447 """
1448 if not xml:
1449 # if xml is not None:
1450 return {xml.tag: xml.text}
1451 result = {}
1452 for child in xml:
1453 child_result = _recursive_parse_xml_to_dict(child)
1454 if child.tag != 'object':
1455 result[child.tag] = child_result[child.tag]
1456 else:
1457 if child.tag not in result:
1458 result[child.tag] = []
1459 result[child.tag].append(child_result[child.tag])
1460 return {xml.tag: result}
1461
1462 if dataset == "2012":
1463 url = "http://host.robots.ox.ac.uk/pascal/VOC/voc2012/"

Callers 1

load_voc_datasetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…