<s> """<STR_LIT>""" <EOL> from contextlib import contextmanager <EOL> import sys <EOL> import types <EOL> import re <EOL> import datetime <EOL> from collections import deque <EOL> string_types = ( str , ) <EOL> from io import StringIO <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> MAX_SEQ_LENGTH = <NUM_LIT:1000> <EOL> _re_pattern_type = type ( re . compile ( '<STR_LIT>' ) ) <EOL> def _safe_getattr ( obj , attr , default = None ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return getattr ( obj , attr , default ) <EOL> except Exception : <EOL> return default <EOL> CUnicodeIO = StringIO <EOL> def pretty ( obj , verbose = False , max_width = <NUM_LIT> , newline = '<STR_LIT:\n>' , max_seq_length = MAX_SEQ_LENGTH ) : <EOL> """<STR_LIT>""" <EOL> stream = CUnicodeIO ( ) <EOL> printer = RepresentationPrinter ( stream , verbose , max_width , newline , max_seq_length = max_seq_length ) <EOL> printer . pretty ( obj ) <EOL> printer . flush ( ) <EOL> return stream . getvalue ( ) <EOL> def pprint ( obj , verbose = False , max_width = <NUM_LIT> , newline = '<STR_LIT:\n>' , max_seq_length = MAX_SEQ_LENGTH ) : <EOL> """<STR_LIT>""" <EOL> printer = RepresentationPrinter ( sys . stdout , verbose , max_width , newline , max_seq_length = max_seq_length ) <EOL> printer . pretty ( obj ) <EOL> printer . flush ( ) <EOL> sys . stdout . write ( newline ) <EOL> sys . stdout . flush ( ) <EOL> class _PrettyPrinterBase ( object ) : <EOL> @ contextmanager <EOL> def indent ( self , indent ) : <EOL> """<STR_LIT>""" <EOL> self . indentation += indent <EOL> try : <EOL> yield <EOL> finally : <EOL> self . indentation -= indent <EOL> @ contextmanager <EOL> def group ( self , indent = <NUM_LIT:0> , open = '<STR_LIT>' , close = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> self . begin_group ( indent , open ) <EOL> try : <EOL> yield <EOL> finally : <EOL> self . end_group ( indent , close ) <EOL> class PrettyPrinter ( _PrettyPrinterBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , output , max_width = <NUM_LIT> , newline = '<STR_LIT:\n>' , max_seq_length = MAX_SEQ_LENGTH ) : <EOL> self . output = output <EOL> self . max_width = max_width <EOL> self . newline = newline <EOL> self . max_seq_length = max_seq_length <EOL> self . output_width = <NUM_LIT:0> <EOL> self . buffer_width = <NUM_LIT:0> <EOL> self . buffer = deque ( ) <EOL> root_group = Group ( <NUM_LIT:0> ) <EOL> self . group_stack = [ root_group ] <EOL> self . group_queue = GroupQueue ( root_group ) <EOL> self . indentation = <NUM_LIT:0> <EOL> def _break_outer_groups ( self ) : <EOL> while self . max_width < self . output_width + self . buffer_width : <EOL> group = self . group_queue . deq ( ) <EOL> if not group : <EOL> return <EOL> while group . breakables : <EOL> x = self . buffer . popleft ( ) <EOL> self . output_width = x . output ( self . output , self . output_width ) <EOL> self . buffer_width -= x . width <EOL> while self . buffer and isinstance ( self . buffer [ <NUM_LIT:0> ] , Text ) : <EOL> x = self . buffer . popleft ( ) <EOL> self . output_width = x . output ( self . output , self . output_width ) <EOL> self . buffer_width -= x . width <EOL> def text ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> width = len ( obj ) <EOL> if self . buffer : <EOL> text = self . buffer [ - <NUM_LIT:1> ] <EOL> if not isinstance ( text , Text ) : <EOL> text = Text ( ) <EOL> self . buffer . append ( text ) <EOL> text . add ( obj , width ) <EOL> self . buffer_width += width <EOL> self . _break_outer_groups ( ) <EOL> else : <EOL> self . output . write ( obj ) <EOL> self . output_width += width <EOL> def breakable ( self , sep = '<STR_LIT:U+0020>' ) : <EOL> """<STR_LIT>""" <EOL> width = len ( sep ) <EOL> group = self . group_stack [ - <NUM_LIT:1> ] <EOL> if group . want_break : <EOL> self . flush ( ) <EOL> self . output . write ( self . newline ) <EOL> self . output . write ( '<STR_LIT:U+0020>' * self . indentation ) <EOL> self . output_width = self . indentation <EOL> self . buffer_width = <NUM_LIT:0> <EOL> else : <EOL> self . buffer . append ( Breakable ( sep , width , self ) ) <EOL> self . buffer_width += width <EOL> self . _break_outer_groups ( ) <EOL> def break_ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . flush ( ) <EOL> self . output . write ( self . newline ) <EOL> self . output . write ( '<STR_LIT:U+0020>' * self . indentation ) <EOL> self . output_width = self . indentation <EOL> self . buffer_width = <NUM_LIT:0> <EOL> def begin_group ( self , indent = <NUM_LIT:0> , open = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if open : <EOL> self . text ( open ) <EOL> group = Group ( self . group_stack [ - <NUM_LIT:1> ] . depth + <NUM_LIT:1> ) <EOL> self . group_stack . append ( group ) <EOL> self . group_queue . enq ( group ) <EOL> self . indentation += indent <EOL> def _enumerate ( self , seq ) : <EOL> """<STR_LIT>""" <EOL> for idx , x in enumerate ( seq ) : <EOL> if self . max_seq_length and idx >= self . max_seq_length : <EOL> self . text ( '<STR_LIT:U+002C>' ) <EOL> self . breakable ( ) <EOL> self . text ( '<STR_LIT>' ) <EOL> return <EOL> yield idx , x <EOL> def end_group ( self , dedent = <NUM_LIT:0> , close = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> self . indentation -= dedent <EOL> group = self . group_stack . pop ( ) <EOL> if not group . breakables : <EOL> self . group_queue . remove ( group ) <EOL> if close : <EOL> self . text ( close ) <EOL> def flush ( self ) : <EOL> """<STR_LIT>""" <EOL> for data in self . buffer : <EOL> self . output_width += data . output ( self . output , self . output_width ) <EOL> self . buffer . clear ( ) <EOL> self . buffer_width = <NUM_LIT:0> <EOL> def _get_mro ( obj_class ) : <EOL> """<STR_LIT>""" <EOL> if not hasattr ( obj_class , '<STR_LIT>' ) : <EOL> try : <EOL> obj_class = type ( obj_class . __name__ , ( obj_class , object ) , { } ) <EOL> except TypeError : <EOL> mro = [ obj_class ] <EOL> else : <EOL> mro = obj_class . __mro__ [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> else : <EOL> mro = obj_class . __mro__ <EOL> return mro <EOL> class RepresentationPrinter ( PrettyPrinter ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , output , verbose = False , max_width = <NUM_LIT> , newline = '<STR_LIT:\n>' , <EOL> singleton_pprinters = None , type_pprinters = None , deferred_pprinters = None , <EOL> max_seq_length = MAX_SEQ_LENGTH ) : <EOL> PrettyPrinter . __init__ ( self , output , max_width , newline , max_seq_length = max_seq_length ) <EOL> self . verbose = verbose <EOL> self . stack = [ ] <EOL> if singleton_pprinters is None : <EOL> singleton_pprinters = _singleton_pprinters . copy ( ) <EOL> self . singleton_pprinters = singleton_pprinters <EOL> if type_pprinters is None : <EOL> type_pprinters = _type_pprinters . copy ( ) <EOL> self . type_pprinters = type_pprinters <EOL> if deferred_pprinters is None : <EOL> deferred_pprinters = _deferred_type_pprinters . copy ( ) <EOL> self . deferred_pprinters = deferred_pprinters <EOL> def pretty ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> obj_id = id ( obj ) <EOL> cycle = obj_id in self . stack <EOL> self . stack . append ( obj_id ) <EOL> self . begin_group ( ) <EOL> try : <EOL> obj_class = _safe_getattr ( obj , '<STR_LIT>' , None ) or type ( obj ) <EOL> try : <EOL> printer = self . singleton_pprinters [ obj_id ] <EOL> except ( TypeError , KeyError ) : <EOL> pass <EOL> else : <EOL> return printer ( obj , self , cycle ) <EOL> for cls in _get_mro ( obj_class ) : <EOL> if cls in self . type_pprinters : <EOL> return self . type_pprinters [ cls ] ( obj , self , cycle ) <EOL> else : <EOL> printer = self . _in_deferred_types ( cls ) <EOL> if printer is not None : <EOL> return printer ( obj , self , cycle ) <EOL> else : <EOL> if '<STR_LIT>' in cls . __dict__ : <EOL> meth = cls . _repr_pretty_ <EOL> if callable ( meth ) : <EOL> return meth ( obj , self , cycle ) <EOL> return _default_pprint ( obj , self , cycle ) <EOL> finally : <EOL> self . end_group ( ) <EOL> self . stack . pop ( ) <EOL> def _in_deferred_types ( self , cls ) : <EOL> """<STR_LIT>""" <EOL> mod = _safe_getattr ( cls , '<STR_LIT>' , None ) <EOL> name = _safe_getattr ( cls , '<STR_LIT>' , None ) <EOL> key = ( mod , name ) <EOL> printer = None <EOL> if key in self . deferred_pprinters : <EOL> printer = self . deferred_pprinters . pop ( key ) <EOL> self . type_pprinters [ cls ] = printer <EOL> return printer <EOL> class Printable ( object ) : <EOL> def output ( self , stream , output_width ) : <EOL> return output_width <EOL> class Text ( Printable ) : <EOL> def __init__ ( self ) : <EOL> self . objs = [ ] <EOL> self . width = <NUM_LIT:0> <EOL> def output ( self , stream , output_width ) : <EOL> for obj in self . objs : <EOL> stream . write ( obj ) <EOL> return output_width + self . width <EOL> def add ( self , obj , width ) : <EOL> self . objs . append ( obj ) <EOL> self . width += width <EOL> class Breakable ( Printable ) : <EOL> def __init__ ( self , seq , width , pretty ) : <EOL> self . obj = seq <EOL> self . width = width <EOL> self . pretty = pretty <EOL> self . indentation = pretty . indentation <EOL> self . group = pretty . group_stack [ - <NUM_LIT:1> ] <EOL> self . group . breakables . append ( self ) <EOL> def output ( self , stream , output_width ) : <EOL> self . group . breakables . popleft ( ) <EOL> if self . group . want_break : <EOL> stream . write ( self . pretty . newline ) <EOL> stream . write ( '<STR_LIT:U+0020>' * self . indentation ) <EOL> return self . indentation <EOL> if not self . group . breakables : <EOL> self . pretty . group_queue . remove ( self . group ) <EOL> stream . write ( self . obj ) <EOL> return output_width + self . width <EOL> class Group ( Printable ) : <EOL> def __init__ ( self , depth ) : <EOL> self . depth = depth <EOL> self . breakables = deque ( ) <EOL> self . want_break = False <EOL> class GroupQueue ( object ) : <EOL> def __init__ ( self , * groups ) : <EOL> self . queue = [ ] <EOL> for group in groups : <EOL> self . enq ( group ) <EOL> def enq ( self , group ) : <EOL> depth = group . depth <EOL> while depth > len ( self . queue ) - <NUM_LIT:1> : <EOL> self . queue . append ( [ ] ) <EOL> self . queue [ depth ] . append ( group ) <EOL> def deq ( self ) : <EOL> for stack in self . queue : <EOL> for idx , group in enumerate ( reversed ( stack ) ) : <EOL> if group . breakables : <EOL> del stack [ idx ] <EOL> group . want_break = True <EOL> return group <EOL> for group in stack : <EOL> group . want_break = True <EOL> del stack [ : ] <EOL> def remove ( self , group ) : <EOL> try : <EOL> self . queue [ group . depth ] . remove ( group ) <EOL> except ValueError : <EOL> pass <EOL> try : <EOL> _baseclass_reprs = ( object . __repr__ , types . InstanceType . __repr__ ) <EOL> except AttributeError : <EOL> _baseclass_reprs = ( object . __repr__ , ) <EOL> def _default_pprint ( obj , p , cycle ) : <EOL> """<STR_LIT>""" <EOL> klass = _safe_getattr ( obj , '<STR_LIT>' , None ) or type ( obj ) <EOL> if _safe_getattr ( klass , '<STR_LIT>' , None ) not in _baseclass_reprs : <EOL> _repr_pprint ( obj , p , cycle ) <EOL> return <EOL> p . begin_group ( <NUM_LIT:1> , '<STR_LIT:<>' ) <EOL> p . pretty ( klass ) <EOL> p . text ( '<STR_LIT>' % id ( obj ) ) <EOL> if cycle : <EOL> p . text ( '<STR_LIT>' ) <EOL> elif p . verbose : <EOL> first = True <EOL> for key in dir ( obj ) : <EOL> if not key . startswith ( '<STR_LIT:_>' ) : <EOL> try : <EOL> value = getattr ( obj , key ) <EOL> except AttributeError : <EOL> continue <EOL> if isinstance ( value , types . MethodType ) : <EOL> continue <EOL> if not first : <EOL> p . text ( '<STR_LIT:U+002C>' ) <EOL> p . breakable ( ) <EOL> p . text ( key ) <EOL> p . text ( '<STR_LIT:=>' ) <EOL> step = len ( key ) + <NUM_LIT:1> <EOL> p . indentation += step <EOL> p . pretty ( value ) <EOL> p . indentation -= step <EOL> first = False <EOL> p . end_group ( <NUM_LIT:1> , '<STR_LIT:>>' ) <EOL> def _seq_pprinter_factory ( start , end , basetype ) : <EOL> """<STR_LIT>""" <EOL> def inner ( obj , p , cycle ) : <EOL> typ = type ( obj ) <EOL> if basetype is not None and typ is not basetype and typ . __repr__ != basetype . __repr__ : <EOL> return p . text ( typ . __repr__ ( obj ) ) <EOL> if cycle : <EOL> return p . text ( start + '<STR_LIT>' + end ) <EOL> step = len ( start ) <EOL> p . begin_group ( step , start ) <EOL> for idx , x in p . _enumerate ( obj ) : <EOL> if idx : <EOL> p . text ( '<STR_LIT:U+002C>' ) <EOL> p . breakable ( ) <EOL> p . pretty ( x ) <EOL> if len ( obj ) == <NUM_LIT:1> and type ( obj ) is tuple : <EOL> p . text ( '<STR_LIT:U+002C>' ) <EOL> p . end_group ( step , end ) <EOL> return inner <EOL> def _set_pprinter_factory ( start , end , basetype ) : <EOL> """<STR_LIT>""" <EOL> def inner ( obj , p , cycle ) : <EOL> typ = type ( obj ) <EOL> if basetype is not None and typ is not basetype and typ . __repr__ != basetype . __repr__ : <EOL> return p . text ( typ . __repr__ ( obj ) ) <EOL> if cycle : <EOL> return p . text ( start + '<STR_LIT>' + end ) <EOL> if len ( obj ) == <NUM_LIT:0> : <EOL> p . text ( basetype . __name__ + '<STR_LIT>' ) <EOL> else : <EOL> step = len ( start ) <EOL> p . begin_group ( step , start ) <EOL> items = obj <EOL> if not ( p . max_seq_length and len ( obj ) >= p . max_seq_length ) : <EOL> try : <EOL> items = sorted ( obj ) <EOL> except Exception : <EOL> pass <EOL> for idx , x in p . _enumerate ( items ) : <EOL> if idx : <EOL> p . text ( '<STR_LIT:U+002C>' ) <EOL> p . breakable ( ) <EOL> p . pretty ( x ) <EOL> p . end_group ( step , end ) <EOL> return inner <EOL> def _dict_pprinter_factory ( start , end , basetype = None ) : <EOL> """<STR_LIT>""" <EOL> def inner ( obj , p , cycle ) : <EOL> typ = type ( obj ) <EOL> if basetype is not None and typ is not basetype and typ . __repr__ != basetype . __repr__ : <EOL> return p . text ( typ . __repr__ ( obj ) ) <EOL> if cycle : <EOL> return p . text ( '<STR_LIT>' ) <EOL> p . begin_group ( <NUM_LIT:1> , start ) <EOL> keys = obj . keys ( ) <EOL> if not ( p . max_seq_length and len ( obj ) >= p . max_seq_length ) : <EOL> try : <EOL> keys = sorted ( keys ) <EOL> except Exception : <EOL> pass <EOL> for idx , key in p . _enumerate ( keys ) : <EOL> if idx : <EOL> p . text ( '<STR_LIT:U+002C>' ) <EOL> p . breakable ( ) <EOL> p . pretty ( key ) <EOL> p . text ( '<STR_LIT>' ) <EOL> p . pretty ( obj [ key ] ) <EOL> p . end_group ( <NUM_LIT:1> , end ) <EOL> return inner <EOL> def _super_pprint ( obj , p , cycle ) : <EOL> """<STR_LIT>""" <EOL> p . begin_group ( <NUM_LIT:8> , '<STR_LIT>' ) <EOL> p . pretty ( obj . __thisclass__ ) <EOL> p . text ( '<STR_LIT:U+002C>' ) <EOL> p . breakable ( ) <EOL> p . pretty ( obj . __self__ ) <EOL> p . end_group ( <NUM_LIT:8> , '<STR_LIT:>>' ) <EOL> def _re_pattern_pprint ( obj , p , cycle ) : <EOL> """<STR_LIT>""" <EOL> p . text ( '<STR_LIT>' ) <EOL> pattern = repr ( obj . pattern ) <EOL> if pattern [ : <NUM_LIT:1> ] in '<STR_LIT>' : <EOL> pattern = pattern [ <NUM_LIT:1> : ] <EOL> prefix = '<STR_LIT>' <EOL> else : <EOL> prefix = '<STR_LIT:r>' <EOL> pattern = prefix + pattern . replace ( '<STR_LIT>' , '<STR_LIT:\\>' ) <EOL> p . text ( pattern ) <EOL> if obj . flags : <EOL> p . text ( '<STR_LIT:U+002C>' ) <EOL> p . breakable ( ) <EOL> done_one = False <EOL> for flag in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if obj . flags & getattr ( re , flag ) : <EOL> if done_one : <EOL> p . text ( '<STR_LIT:|>' ) <EOL> p . text ( '<STR_LIT>' + flag ) <EOL> done_one = True <EOL> p . text ( '<STR_LIT:)>' ) <EOL> def _type_pprint ( obj , p , cycle ) : <EOL> """<STR_LIT>""" <EOL> if type ( obj ) . __repr__ is not type . __repr__ : <EOL> _repr_pprint ( obj , p , cycle ) <EOL> return <EOL> mod = _safe_getattr ( obj , '<STR_LIT>' , None ) <EOL> try : <EOL> name = obj . __qualname__ <EOL> if not isinstance ( name , string_types ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> except Exception : <EOL> name = obj . __name__ <EOL> if not isinstance ( name , string_types ) : <EOL> name = '<STR_LIT>' <EOL> if mod in ( None , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> p . text ( name ) <EOL> else : <EOL> p . text ( mod + '<STR_LIT:.>' + name ) <EOL> def _repr_pprint ( obj , p , cycle ) : <EOL> """<STR_LIT>""" <EOL> output = repr ( obj ) <EOL> for idx , output_line in enumerate ( output . splitlines ( ) ) : <EOL> if idx : <EOL> p . break_ ( ) <EOL> p . text ( output_line ) <EOL> def _function_pprint ( obj , p , cycle ) : <EOL> """<STR_LIT>""" <EOL> name = _safe_getattr ( obj , '<STR_LIT>' , obj . __name__ ) <EOL> mod = obj . __module__ <EOL> if mod and mod not in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> name = mod + '<STR_LIT:.>' + name <EOL> p . text ( '<STR_LIT>' % name ) <EOL> def _exception_pprint ( obj , p , cycle ) : <EOL> """<STR_LIT>""" <EOL> name = getattr ( obj . __class__ , '<STR_LIT>' , obj . __class__ . __name__ ) <EOL> if obj . __class__ . __module__ not in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> name = '<STR_LIT>' % ( obj . __class__ . __module__ , name ) <EOL> step = len ( name ) + <NUM_LIT:1> <EOL> p . begin_group ( step , name + '<STR_LIT:(>' ) <EOL> for idx , arg in enumerate ( getattr ( obj , '<STR_LIT:args>' , ( ) ) ) : <EOL> if idx : <EOL> p . text ( '<STR_LIT:U+002C>' ) <EOL> p . breakable ( ) <EOL> p . pretty ( arg ) <EOL> p . end_group ( step , '<STR_LIT:)>' ) <EOL> try : <EOL> _exception_base = BaseException <EOL> except NameError : <EOL> _exception_base = Exception <EOL> _type_pprinters = { <EOL> int : _repr_pprint , <EOL> float : _repr_pprint , <EOL> str : _repr_pprint , <EOL> tuple : _seq_pprinter_factory ( '<STR_LIT:(>' , '<STR_LIT:)>' , tuple ) , <EOL> list : _seq_pprinter_factory ( '<STR_LIT:[>' , '<STR_LIT:]>' , list ) , <EOL> dict : _dict_pprinter_factory ( '<STR_LIT:{>' , '<STR_LIT:}>' , dict ) , <EOL> set : _set_pprinter_factory ( '<STR_LIT:{>' , '<STR_LIT:}>' , set ) , <EOL> frozenset : _set_pprinter_factory ( '<STR_LIT>' , '<STR_LIT>' , frozenset ) , <EOL> super : _super_pprint , <EOL> _re_pattern_type : _re_pattern_pprint , <EOL> type : _type_pprint , <EOL> types . FunctionType : _function_pprint , <EOL> types . BuiltinFunctionType : _function_pprint , <EOL> types . MethodType : _repr_pprint , <EOL> datetime . datetime : _repr_pprint , <EOL> datetime . timedelta : _repr_pprint , <EOL> _exception_base : _exception_pprint <EOL> } <EOL> try : <EOL> _type_pprinters [ types . DictProxyType ] = _dict_pprinter_factory ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> _type_pprinters [ types . ClassType ] = _type_pprint <EOL> _type_pprinters [ types . SliceType ] = _repr_pprint <EOL> except AttributeError : <EOL> _type_pprinters [ slice ] = _repr_pprint <EOL> try : <EOL> _type_pprinters [ xrange ] = _repr_pprint <EOL> _type_pprinters [ long ] = _repr_pprint <EOL> _type_pprinters [ unicode ] = _repr_pprint <EOL> except NameError : <EOL> _type_pprinters [ range ] = _repr_pprint <EOL> _type_pprinters [ bytes ] = _repr_pprint <EOL> _deferred_type_pprinters = { <EOL> } <EOL> def for_type ( typ , func ) : <EOL> """<STR_LIT>""" <EOL> oldfunc = _type_pprinters . get ( typ , None ) <EOL> if func is not None : <EOL> _type_pprinters [ typ ] = func <EOL> return oldfunc <EOL> def for_type_by_name ( type_module , type_name , func ) : <EOL> """<STR_LIT>""" <EOL> key = ( type_module , type_name ) <EOL> oldfunc = _deferred_type_pprinters . get ( key , None ) <EOL> if func is not None : <EOL> _deferred_type_pprinters [ key ] = func <EOL> return oldfunc <EOL> _singleton_pprinters = dict . fromkeys ( map ( id , [ None , True , False , Ellipsis , <EOL> NotImplemented ] ) , _repr_pprint ) <EOL> def _defaultdict_pprint ( obj , p , cycle ) : <EOL> name = obj . __class__ . __name__ <EOL> with p . group ( len ( name ) + <NUM_LIT:1> , name + '<STR_LIT:(>' , '<STR_LIT:)>' ) : <EOL> if cycle : <EOL> p . text ( '<STR_LIT>' ) <EOL> else : <EOL> p . pretty ( obj . default_factory ) <EOL> p . text ( '<STR_LIT:U+002C>' ) <EOL> p . breakable ( ) <EOL> p . pretty ( dict ( obj ) ) <EOL> def _ordereddict_pprint ( obj , p , cycle ) : <EOL> name = obj . __class__ . __name__ <EOL> with p . group ( len ( name ) + <NUM_LIT:1> , name + '<STR_LIT:(>' , '<STR_LIT:)>' ) : <EOL> if cycle : <EOL> p . text ( '<STR_LIT>' ) <EOL> elif len ( obj ) : <EOL> p . pretty ( list ( obj . items ( ) ) ) <EOL> def _deque_pprint ( obj , p , cycle ) : <EOL> name = obj . __class__ . __name__ <EOL> with p . group ( len ( name ) + <NUM_LIT:1> , name + '<STR_LIT:(>' , '<STR_LIT:)>' ) : <EOL> if cycle : <EOL> p . text ( '<STR_LIT>' ) <EOL> else : <EOL> p . pretty ( list ( obj ) ) <EOL> def _counter_pprint ( obj , p , cycle ) : <EOL> name = obj . __class__ . __name__ <EOL> with p . group ( len ( name ) + <NUM_LIT:1> , name + '<STR_LIT:(>' , '<STR_LIT:)>' ) : <EOL> if cycle : <EOL> p . text ( '<STR_LIT>' ) <EOL> elif len ( obj ) : <EOL> p . pretty ( dict ( obj ) ) <EOL> for_type_by_name ( '<STR_LIT>' , '<STR_LIT>' , _defaultdict_pprint ) <EOL> for_type_by_name ( '<STR_LIT>' , '<STR_LIT>' , _ordereddict_pprint ) <EOL> for_type_by_name ( '<STR_LIT>' , '<STR_LIT>' , _deque_pprint ) <EOL> for_type_by_name ( '<STR_LIT>' , '<STR_LIT>' , _counter_pprint ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from random import randrange <EOL> class Foo ( object ) : <EOL> def __init__ ( self ) : <EOL> self . foo = <NUM_LIT:1> <EOL> self . bar = re . compile ( r'<STR_LIT>' ) <EOL> self . blub = dict . fromkeys ( range ( <NUM_LIT:30> ) , randrange ( <NUM_LIT:1> , <NUM_LIT> ) ) <EOL> self . hehe = <NUM_LIT> <EOL> self . list = [ "<STR_LIT>" , "<STR_LIT>" , self ] <EOL> def get_foo ( self ) : <EOL> print ( "<STR_LIT:foo>" ) <EOL> pprint ( Foo ( ) , verbose = True ) </s>
