FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

PyMJCF nested include tags relative to base model by guyazran · Pull Request #417 · google-deepmind/dm_control · GitHub

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 6 additions & 3 deletions dm_control/mjcf/parser.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def from_file(file_handle, escape_separators=False,


def from_path(path, escape_separators=False, resolve_references=True,
assets=None):
assets=None, model_dir=None):
"""Parses an XML file into an MJCF object model.

Args:
Expand All @@ -94,11 +94,14 @@ def from_path(path, escape_separators=False, resolve_references=True,
assets: (optional) A dictionary of pre-loaded assets, of the form
`{filename: bytestring}`. If present, PyMJCF will search for assets in
this dictionary before attempting to load them from the filesystem.
model_dir: (optional) Path to the directory containing the model XML file.
This is used to prefix the paths of all asset files.

Returns:
An `mjcf.RootElement`.
"""
model_dir, _ = os.path.split(path)
if model_dir is None:
model_dir, _ = os.path.split(path)
contents = resources.GetResource(path)
xml_root = etree.fromstring(contents)
return _parse(xml_root, escape_separators,
Expand Down Expand Up @@ -153,7 +156,7 @@ def _parse(xml_root, escape_separators=False,
path_or_xml_string,
escape_separators=escape_separators,
resolve_references=resolve_references,
assets=assets)
assets=assets, model_dir=model_dir)
to_include.append(included_mjcf)
# We must remove <include/> tags before parsing the main XML file, since
# these are a schema violation.
Expand Down

Back | FazBrowse Home | New Git URL