#NEWLINE# def _obj_to_path( obj ) : #NEWLINE# #INDENT# "Returns the fully qualified path to the object.\n\n  Args:\n    obj: obj must be a new style top level class, or a top level function.\n      No inner function or static method.\n\n  Returns:\n    Fully qualified path to the object.\n\n  Raises:\n    TypeError: when argument obj has unsupported type.\n    ValueError: when obj can't be discovered on the top level.\n  " #NEWLINE# if ( obj is None ) : #NEWLINE# #INDENT# return obj #NEWLINE# #UNINDENT# if ( inspect . isclass ( obj ) or inspect . isfunction ( obj ) ) : #NEWLINE# #INDENT# fetched = getattr ( sys . modules [ obj . __module__ ] , obj . __name__ , None ) #NEWLINE# if ( fetched is None ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Object %r must be defined on the top level of a module.' % obj ) ) #NEWLINE# #UNINDENT# return ( '%s.%s' % ( obj . __module__ , fetched . __name__ ) ) #NEWLINE# #UNINDENT# raise TypeError ( ( 'Unexpected type %s.' % type ( obj ) ) )