in mujoco_worldgen/util/obj_util.py [0:0]
def recursive_rename(xml_dict, prefix):
attrs = ["@name", "@joint", "@jointinparent", "@class", "@source",
"@target", "@childclass", "@body1", "@body2", "@mesh",
"@joint1", "@joint2", "@geom", "@geom1", "@geom2", "@site",
"@material", "@texture", "@tendon", "@sidesite", "@actuator"]
names = ["geom", "joint", "jointinparent", "body", "motor", "freejoint", "general",
"position", "default", "weld", "exclude", "mesh",
"site", "pair", "jointpos", "touch", "texture", "material",
"fixed", "spatial", "motor", "actuatorfrc"]
if not isinstance(xml_dict, OrderedDict):
return
for key in list(xml_dict.keys()):
value_dict = xml_dict[key]
if isinstance(value_dict, OrderedDict):
value_dict = [value_dict]
if key in names:
assert isinstance(
value_dict, list), "Invalid type for value {}".format(value_dict)
for value in value_dict:
for attr in list(value.keys()):
if attr in attrs:
if not value[attr].startswith(prefix + ':'):
value[attr] = prefix + ':' + value[attr]
if isinstance(value_dict, list):
for value in value_dict:
recursive_rename(value, prefix)