MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / find_element

Function find_element

dm_control/utils/xml_tools.py:23–41  ·  view source on GitHub ↗

Finds and returns the first element of specified tag and name. Args: root: `etree.Element` to be searched recursively. tag: The `tag` property of the sought element. name: The `name` attribute of the sought element. Returns: An `etree.Element` with the specified properties.

(root, tag, name)

Source from the content-addressed store, hash-verified

21
22
23def find_element(root, tag, name):
24 """Finds and returns the first element of specified tag and name.
25
26 Args:
27 root: `etree.Element` to be searched recursively.
28 tag: The `tag` property of the sought element.
29 name: The `name` attribute of the sought element.
30
31 Returns:
32 An `etree.Element` with the specified properties.
33
34 Raises:
35 ValueError: If no matching element is found.
36 """
37 result = root.find('.//{}[@name={!r}]'.format(tag, name))
38 if result is None:
39 raise ValueError(
40 'Element with tag {!r} and name {!r} not found'.format(tag, name))
41 return result
42
43
44def nested_element(element, depth):

Callers

nothing calls this directly

Calls 1

findMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…