#NEWLINE# def getAttributeNames( object , includeMagic = 1 , includeSingle = 1 , includeDouble = 1 ) : #NEWLINE# #INDENT# 'Return list of unique attributes, including inherited, for object.' #NEWLINE# attributes = [ ] #NEWLINE# dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( not introspect . hasattrAlwaysReturnsTrue ( object ) ) : #NEWLINE# #INDENT# special_attrs = [ '__bases__' , '__class__' , '__dict__' , '__name__' , 'func_closure' , 'func_code' , 'func_defaults' , 'func_dict' , 'func_doc' , 'func_globals' , 'func_name' ] #NEWLINE# attributes += [ attr for attr in special_attrs if hasattr ( object , attr ) ] #NEWLINE# #UNINDENT# if hasattr ( object , 'trait_names' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# attributes += object . trait_names ( ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# if includeMagic : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# attributes += object . _getAttributeNames ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# attrdict = getAllAttributeNames ( object ) #NEWLINE# object_dir = dir ( attrdict ) #NEWLINE# for ( ( obj_type_name , technique , count ) , attrlist ) in attrdict . items ( ) : #NEWLINE# #INDENT# if ( ( type ( object ) . __name__ == obj_type_name ) and ( technique == 'dir' ) ) : #NEWLINE# #INDENT# attributes += attrlist #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# attributes += [ attr for attr in attrlist if ( ( attr not in object_dir ) and hasattr ( object , attr ) ) ] #NEWLINE# #UNINDENT# #UNINDENT# for item in attributes : #NEWLINE# #INDENT# dict [ item ] = None #NEWLINE# #UNINDENT# attributes = dict . keys ( ) #NEWLINE# attributes = [ attribute for attribute in attributes if isinstance ( attribute , basestring ) ] #NEWLINE# attributes . sort ( ( lambda x , y : cmp ( x . upper ( ) , y . upper ( ) ) ) ) #NEWLINE# if ( not includeSingle ) : #NEWLINE# #INDENT# attributes = filter ( ( lambda item : ( ( item [ 0 ] != '_' ) or ( item [ 1 ] == '_' ) ) ) , attributes ) #NEWLINE# #UNINDENT# if ( not includeDouble ) : #NEWLINE# #INDENT# attributes = filter ( ( lambda item : ( item [ : 2 ] != '__' ) ) , attributes ) #NEWLINE# #UNINDENT# return attributes