def import_from_string(val, setting_name):
 try:
  parts = val.split(u'.')
  (module_path, class_name) = (u'.'.join(parts[:(-1)]), parts[(-1)])
  module = importlib.import_module(module_path)
  return getattr(module, class_name)
 except (ImportError, AttributeError) as e:
  msg = (u"Could not import '%s' for API setting '%s'. %s: %s." % (val, setting_name, e.__class__.__name__, e))
  raise ImportError(msg)

def import_from_string ( val , setting_name ) : try : parts = val . split ( u'.' ) ( module_path , class_name ) = ( u'.' . join ( parts [ : ( - 1 ) ] ) , parts [ ( - 1 ) ] ) module = importlib . import_module ( module_path ) return getattr ( module , class_name ) except ( ImportError , AttributeError ) as e : msg = ( u"Could not import '%s' for API setting '%s'. %s: %s." % ( val , setting_name , e . __class__ . __name__ , e ) ) raise ImportError ( msg )
attempt to import a class from a string representation .