#NEWLINE# def lookup_object( spec ) : #NEWLINE# #INDENT# '\n    Looks up a module or object from a some.module:func_name specification.\n    To just look up a module, omit the colon and everything after it.\n    ' #NEWLINE# ( parts , target ) = ( spec . split ( ':' ) if ( ':' in spec ) else ( spec , None ) ) #NEWLINE# module = __import__ ( parts ) #NEWLINE# for part in ( parts . split ( '.' ) [ 1 : ] + ( [ target ] if target else [ ] ) ) : #NEWLINE# #INDENT# module = getattr ( module , part ) #NEWLINE# #UNINDENT# return module