(attribute_xml)
return AttributeSpec(
      name=name, type=attribute_callable, required=required,
      conflict_allowed=conflict_allowed, conflict_behavior=conflict_behavior,
      other_kwargs=other_kwargs)
Parses an <attribute> element in the schema.
Parses an <attribute> element in the schema.
Parses an <attribute > element in the schema .
def _parse_attribute(attribute_xml):
  """Parses an <attribute> element in the schema."""
  name = attribute_xml.get('name')
  required = _str2bool(attribute_xml.get('required'))
  conflict_allowed = _str2bool(attribute_xml.get('conflict_allowed'))
  conflict_behavior = attribute_xml.get('conflict_behavior', 'replace')
  attribute_type = attribute_xml.get('type')
  other_kwargs = {}
  if attribute_type == 'keyword':
    attribute_callable = attribute.Keyword
    other_kwargs['valid_values'] = attribute_xml.get('valid_values').split(' ')
  elif attribute_type == 'array':
    array_size_str = attribute_xml.get('array_size')
    attribute_callable = attribute.Array
    other_kwargs['length'] = int(array_size_str) if array_size_str else None
    other_kwargs['dtype'] = _ARRAY_DTYPE_MAP[attribute_xml.get('array_type')]
  elif attribute_type == 'identifier':
    attribute_callable = attribute.Identifier
  elif attribute_type == 'reference':
    attribute_callable = attribute.Reference
    other_kwargs['reference_namespace'] = (
        attribute_xml.get('reference_namespace') or name)
  elif attribute_type == 'basepath':
    attribute_callable = attribute.BasePath
    other_kwargs['path_namespace'] = attribute_xml.get('path_namespace')
  elif attribute_type == 'file':
    attribute_callable = attribute.File
    other_kwargs['path_namespace'] = attribute_xml.get('path_namespace')
  else:
    try:
      attribute_callable = _SCALAR_TYPE_MAP[attribute_type]
    except KeyError:
      raise ValueError('Invalid attribute type: {}'.format(attribute_type))

  return AttributeSpec(
      name=name, type=attribute_callable, required=required,
      conflict_allowed=conflict_allowed, conflict_behavior=conflict_behavior,
      other_kwargs=other_kwargs)
def _parse_attribute ( attribute_xml ) : name = attribute_xml . get ( 'name' ) required = _str2bool ( attribute_xml . get ( 'required' ) ) conflict_allowed = _str2bool ( attribute_xml . get ( 'conflict_allowed' ) ) conflict_behavior = attribute_xml . get ( 'conflict_behavior' , 'replace' ) attribute_type = attribute_xml . get ( 'type' ) other_kwargs = { } if attribute_type == 'keyword' : attribute_callable = attribute . Keyword other_kwargs [ 'valid_values' ] = attribute_xml . get ( 'valid_values' ) . split ( ' ' ) elif attribute_type == 'array' : array_size_str = attribute_xml . get ( 'array_size' ) attribute_callable = attribute . Array other_kwargs [ 'length' ] = int ( array_size_str ) if array_size_str else None other_kwargs [ 'dtype' ] = _ARRAY_DTYPE_MAP [ attribute_xml . get ( 'array_type' ) ] elif attribute_type == 'identifier' : attribute_callable = attribute . Identifier elif attribute_type == 'reference' : attribute_callable = attribute . Reference other_kwargs [ 'reference_namespace' ] = ( attribute_xml . get ( 'reference_namespace' ) or name ) elif attribute_type == 'basepath' : attribute_callable = attribute . BasePath other_kwargs [ 'path_namespace' ] = attribute_xml . get ( 'path_namespace' ) elif attribute_type == 'file' : attribute_callable = attribute . File other_kwargs [ 'path_namespace' ] = attribute_xml . get ( 'path_namespace' ) else : try : attribute_callable = _SCALAR_TYPE_MAP [ attribute_type ] except KeyError : raise ValueError ( 'Invalid attribute type: {}' . format ( attribute_type ) ) return AttributeSpec ( name = name , type = attribute_callable , required = required , conflict_allowed = conflict_allowed , conflict_behavior = conflict_behavior , other_kwargs = other_kwargs )