#NEWLINE# def pretty( self , obj ) : #NEWLINE# #INDENT# 'Pretty print the given object.' #NEWLINE# obj_id = id ( obj ) #NEWLINE# cycle = ( obj_id in self . stack ) #NEWLINE# self . stack . append ( obj_id ) #NEWLINE# self . begin_group ( ) #NEWLINE# try : #NEWLINE# #INDENT# obj_class = ( getattr ( obj , '__class__' , None ) or type ( obj ) ) #NEWLINE# try : #NEWLINE# #INDENT# printer = self . singleton_pprinters [ obj_id ] #NEWLINE# #UNINDENT# except ( TypeError , KeyError ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return printer ( obj , self , cycle ) #NEWLINE# #UNINDENT# for cls in _get_mro ( obj_class ) : #NEWLINE# #INDENT# if ( cls in self . type_pprinters ) : #NEWLINE# #INDENT# return self . type_pprinters [ cls ] ( obj , self , cycle ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# printer = self . _in_deferred_types ( cls ) #NEWLINE# if ( printer is not None ) : #NEWLINE# #INDENT# return printer ( obj , self , cycle ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if hasattr ( obj_class , '_repr_pretty_' ) : #NEWLINE# #INDENT# return obj_class . _repr_pretty_ ( obj , self , cycle ) #NEWLINE# #UNINDENT# return _default_pprint ( obj , self , cycle ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# self . end_group ( ) #NEWLINE# self . stack . pop ( )