#NEWLINE# def class_from_module( path , defaultpaths = None ) : #NEWLINE# #INDENT# "\n    Return a class from a module, given the module's path. This is\n    primarily used to convert db_typeclass_path:s to classes.\n\n    Args:\n        path (str): Full Python dot-path to module.\n        defaultpaths (iterable, optional): If a direc import from `path` fails,\n            try subsequent imports by prepending those paths to `path`.\n\n    Returns:\n        class (Class): An uninstatiated class recovered from path.\n\n    Raises:\n        ImportError: If all loading failed.\n\n    " #NEWLINE# cls = None #NEWLINE# if defaultpaths : #NEWLINE# #INDENT# paths = ( ( [ path ] + [ ( '%s.%s' % ( dpath , path ) ) for dpath in make_iter ( defaultpaths ) ] ) if defaultpaths else [ ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# paths = [ path ] #NEWLINE# #UNINDENT# for testpath in paths : #NEWLINE# #INDENT# if ( '.' in path ) : #NEWLINE# #INDENT# ( testpath , clsname ) = testpath . rsplit ( '.' , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ImportError ( ( "the path '%s' is not on the form modulepath.Classname." % path ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# mod = import_module ( testpath , package = 'evennia' ) #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# if ( len ( trace ( ) ) > 2 ) : #NEWLINE# #INDENT# exc = sys . exc_info ( ) #NEWLINE# raise_ ( exc [ 1 ] , None , exc [ 2 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# cls = getattr ( mod , clsname ) #NEWLINE# break #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# if ( len ( trace ( ) ) > 2 ) : #NEWLINE# #INDENT# exc = sys . exc_info ( ) #NEWLINE# raise_ ( exc [ 1 ] , None , exc [ 2 ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not cls ) : #NEWLINE# #INDENT# err = ( "Could not load typeclass '%s'" % path ) #NEWLINE# if defaultpaths : #NEWLINE# #INDENT# err += ( '\nPaths searched:\n    %s' % '\n    ' . join ( paths ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# err += '.' #NEWLINE# #UNINDENT# raise ImportError ( err ) #NEWLINE# #UNINDENT# return cls