#NEWLINE# def resolve_name( name ) : #NEWLINE# #INDENT# ret = None #NEWLINE# parts = name . split ( '.' ) #NEWLINE# cursor = len ( parts ) #NEWLINE# module_name = parts [ : cursor ] #NEWLINE# last_exc = None #NEWLINE# while ( cursor > 0 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ret = __import__ ( '.' . join ( module_name ) ) #NEWLINE# break #NEWLINE# #UNINDENT# except ImportError as exc : #NEWLINE# #INDENT# last_exc = exc #NEWLINE# if ( cursor == 0 ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# cursor -= 1 #NEWLINE# module_name = parts [ : cursor ] #NEWLINE# #UNINDENT# #UNINDENT# for part in parts [ 1 : ] : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ret = getattr ( ret , part ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# if ( last_exc is not None ) : #NEWLINE# #INDENT# raise last_exc #NEWLINE# #UNINDENT# raise ImportError ( name ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ret is None ) : #NEWLINE# #INDENT# if ( last_exc is not None ) : #NEWLINE# #INDENT# raise last_exc #NEWLINE# #UNINDENT# raise ImportError ( cursor ) #NEWLINE# #UNINDENT# return ret