MCPcopy Index your code
hub / github.com/google-deepmind/dm_control / from_xml_string

Function from_xml_string

dm_control/mjcf/parser.py:31–55  ·  view source on GitHub ↗

Parses an XML string into an MJCF object model. Args: xml_string: An XML string representing an MJCF model. escape_separators: (optional) A boolean, whether to replace '/' characters in element identifiers. If `False`, any '/' present in the XML causes a ValueError to be raise

(xml_string, escape_separators=False,
                    model_dir='', resolve_references=True, assets=None)

Source from the content-addressed store, hash-verified

29
30
31def from_xml_string(xml_string, escape_separators=False,
32 model_dir='', resolve_references=True, assets=None):
33 """Parses an XML string into an MJCF object model.
34
35 Args:
36 xml_string: An XML string representing an MJCF model.
37 escape_separators: (optional) A boolean, whether to replace '/' characters
38 in element identifiers. If `False`, any '/' present in the XML causes
39 a ValueError to be raised.
40 model_dir: (optional) Path to the directory containing the model XML file.
41 This is used to prefix the paths of all asset files.
42 resolve_references: (optional) A boolean indicating whether the parser
43 should attempt to resolve reference attributes to a corresponding element.
44 assets: (optional) A dictionary of pre-loaded assets, of the form
45 `{filename: bytestring}`. If present, PyMJCF will search for assets in
46 this dictionary before attempting to load them from the filesystem.
47
48 Returns:
49 An `mjcf.RootElement`.
50 """
51 xml_root = etree.fromstring(xml_string)
52 return _parse(xml_root, escape_separators,
53 model_dir=model_dir,
54 resolve_references=resolve_references,
55 assets=assets)
56
57
58def from_file(file_handle, escape_separators=False,

Callers

nothing calls this directly

Calls 1

_parseFunction · 0.85

Tested by

no test coverage detected