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

Function from_file

dm_control/mjcf/parser.py:58–82  ·  view source on GitHub ↗

Parses an XML file into an MJCF object model. Args: file_handle: A Python file-like handle. escape_separators: (optional) A boolean, whether to replace '/' characters in element identifiers. If `False`, any '/' present in the XML causes a ValueError to be raised. model_dir

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

Source from the content-addressed store, hash-verified

56
57
58def from_file(file_handle, escape_separators=False,
59 model_dir='', resolve_references=True, assets=None):
60 """Parses an XML file into an MJCF object model.
61
62 Args:
63 file_handle: A Python file-like handle.
64 escape_separators: (optional) A boolean, whether to replace '/' characters
65 in element identifiers. If `False`, any '/' present in the XML causes
66 a ValueError to be raised.
67 model_dir: (optional) Path to the directory containing the model XML file.
68 This is used to prefix the paths of all asset files.
69 resolve_references: (optional) A boolean indicating whether the parser
70 should attempt to resolve reference attributes to a corresponding element.
71 assets: (optional) A dictionary of pre-loaded assets, of the form
72 `{filename: bytestring}`. If present, PyMJCF will search for assets in
73 this dictionary before attempting to load them from the filesystem.
74
75 Returns:
76 An `mjcf.RootElement`.
77 """
78 xml_root = etree.parse(file_handle).getroot()
79 return _parse(xml_root, escape_separators,
80 model_dir=model_dir,
81 resolve_references=resolve_references,
82 assets=assets)
83
84
85def from_path(path, escape_separators=False, resolve_references=True,

Callers

nothing calls this directly

Calls 1

_parseFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…