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

Function from_path

dm_control/mjcf/parser.py:85–109  ·  view source on GitHub ↗

Parses an XML file into an MJCF object model. Args: path: A path to an XML file. This path should be loadable using `resources.GetResource`. escape_separators: (optional) A boolean, whether to replace '/' characters in element identifiers. If `False`, any '/' present in the XM

(path, escape_separators=False, resolve_references=True,
              assets=None)

Source from the content-addressed store, hash-verified

83
84
85def from_path(path, escape_separators=False, resolve_references=True,
86 assets=None):
87 """Parses an XML file into an MJCF object model.
88
89 Args:
90 path: A path to an XML file. This path should be loadable using
91 `resources.GetResource`.
92 escape_separators: (optional) A boolean, whether to replace '/' characters
93 in element identifiers. If `False`, any '/' present in the XML causes
94 a ValueError to be raised.
95 resolve_references: (optional) A boolean indicating whether the parser
96 should attempt to resolve reference attributes to a corresponding element.
97 assets: (optional) A dictionary of pre-loaded assets, of the form
98 `{filename: bytestring}`. If present, PyMJCF will search for assets in
99 this dictionary before attempting to load them from the filesystem.
100
101 Returns:
102 An `mjcf.RootElement`.
103 """
104 model_dir, _ = os.path.split(path)
105 contents = resources.GetResource(path)
106 xml_root = etree.fromstring(contents)
107 return _parse(xml_root, escape_separators,
108 model_dir=model_dir, resolve_references=resolve_references,
109 assets=assets)
110
111
112def from_zip(path, model_file='model.xml', escape_separators=False,

Callers

nothing calls this directly

Calls 1

_parseFunction · 0.85

Tested by

no test coverage detected