(element, attributes=None)
Commits default values into attributes of the specified element.

  Args:
    element: A PyMJCF element.
    attributes: (optional) A list of strings specifying the attributes to be
      copied from defaults, or `None` if all attributes should be copied.
Commits default values into attributes of the specified element.
Commits default values into attributes of the specified element .
def commit_defaults(element, attributes=None):
  """Commits default values into attributes of the specified element.

  Args:
    element: A PyMJCF element.
    attributes: (optional) A list of strings specifying the attributes to be
      copied from defaults, or `None` if all attributes should be copied.
  """
  dclass = element.dclass
  parent = element.parent
  while dclass is None and parent != element.root:
    dclass = getattr(parent, 'childclass', None)
    parent = parent.parent
  if dclass is None:
    dclass = element.root.default

  while dclass != element.root:
    if element.tag in _ACTUATOR_TAGS:
      tags = _ACTUATOR_TAGS
    else:
      tags = (element.tag,)
    for tag in tags:
      default_element = getattr(dclass, tag)
      for name, value in default_element.get_attributes().items():
        if attributes is None or name in attributes:
          if hasattr(element, name) and getattr(element, name) is None:
            setattr(element, name, value)
    dclass = dclass.parent
def commit_defaults ( element , attributes = None ) : dclass = element . dclass parent = element . parent while dclass is None and parent != element . root : dclass = getattr ( parent , 'childclass' , None ) parent = parent . parent if dclass is None : dclass = element . root . default while dclass != element . root : if element . tag in _ACTUATOR_TAGS : tags = _ACTUATOR_TAGS else : tags = ( element . tag , ) for tag in tags : default_element = getattr ( dclass , tag ) for name , value in default_element . get_attributes ( ) . items ( ) : if attributes is None or name in attributes : if hasattr ( element , name ) and getattr ( element , name ) is None : setattr ( element , name , value ) dclass = dclass . parent