#NEWLINE# def get_module_callables( mod , ignore = None ) : #NEWLINE# #INDENT# 'Returns two maps of (*types*, *funcs*) from *mod*, optionally\n    ignoring based on the :class:`bool` return value of the *ignore*\n    callable. *mod* can be a string name of a module in\n    :data:`sys.modules` or the module instance itself.\n    ' #NEWLINE# if isinstance ( mod , basestring ) : #NEWLINE# #INDENT# mod = sys . modules [ mod ] #NEWLINE# #UNINDENT# ( types , funcs ) = ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# for attr_name in dir ( mod ) : #NEWLINE# #INDENT# if ( ignore and ignore ( attr_name ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# attr = getattr ( mod , attr_name ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# attr_mod_name = attr . __module__ #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( attr_mod_name != mod . __name__ ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if isinstance ( attr , type ) : #NEWLINE# #INDENT# types [ attr_name ] = attr #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if callable ( attr ) : #NEWLINE# #INDENT# funcs [ attr_name ] = attr #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( types , funcs )