def select_from_attribute(attribute_value, path):
 def get_path_component(collection, key):
  if (not isinstance(collection, (collections.Mapping, collections.Sequence))):
   raise TypeError(_("Can't traverse attribute path"))
  if (not isinstance(key, (six.string_types, int))):
   raise TypeError(_('Path components in attributes must be strings'))
  return collection[key]
 try:
  return six.moves.reduce(get_path_component, path, attribute_value)
 except (KeyError, IndexError, TypeError):
  return None

def select_from_attribute ( attribute_value , path ) : def get_path_component ( collection , key ) : if ( not isinstance ( collection , ( collections . Mapping , collections . Sequence ) ) ) : raise TypeError ( _ ( "Can't traverse attribute path" ) ) if ( not isinstance ( key , ( six . string_types , int ) ) ) : raise TypeError ( _ ( 'Path components in attributes must be strings' ) ) return collection [ key ] try : return six . moves . reduce ( get_path_component , path , attribute_value ) except ( KeyError , IndexError , TypeError ) : return None
select an element from an attribute value .