#NEWLINE# def import_by_path( dotted_path , error_prefix = '' ) : #NEWLINE# #INDENT# '\n    Import a dotted module path and return the attribute/class designated by\n    the last name in the path. Raise ImproperlyConfigured if something goes\n    wrong.\n\n    Backported from Django 1.6.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# ( module_path , class_name ) = dotted_path . rsplit ( '.' , 1 ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise ImproperlyConfigured ( "{0}{1} doesn't look like a module path" . format ( error_prefix , dotted_path ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# module = import_module ( module_path ) #NEWLINE# #UNINDENT# except ImportError as err : #NEWLINE# #INDENT# msg = '{0}Error importing module {1}: "{2}"' . format ( error_prefix , module_path , err ) #NEWLINE# six . reraise ( ImproperlyConfigured , ImproperlyConfigured ( msg ) , sys . exc_info ( ) [ 2 ] ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# attr = getattr ( module , class_name ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# raise ImproperlyConfigured ( '{0}Module "{1}" does not define a "{2}" attribute/class' . format ( error_prefix , module_path , class_name ) ) #NEWLINE# #UNINDENT# return attr