##// END OF EJS Templates
make max_seq_length an attr on PrettyPrinter...
MinRK -
Show More
@@ -122,8 +122,6 b' else:'
122 __all__ = ['pretty', 'pprint', 'PrettyPrinter', 'RepresentationPrinter',
122 __all__ = ['pretty', 'pprint', 'PrettyPrinter', 'RepresentationPrinter',
123 'for_type', 'for_type_by_name']
123 'for_type', 'for_type_by_name']
124
124
125 SEQ_LENGTH_LIMIT = 1000
126
127 _re_pattern_type = type(re.compile(''))
125 _re_pattern_type = type(re.compile(''))
128
126
129 def _failed_repr(obj, e):
127 def _failed_repr(obj, e):
@@ -230,10 +228,11 b' class PrettyPrinter(_PrettyPrinterBase):'
230 callback method.
228 callback method.
231 """
229 """
232
230
233 def __init__(self, output, max_width=79, newline='\n'):
231 def __init__(self, output, max_width=79, newline='\n', max_seq_length=1000):
234 self.output = output
232 self.output = output
235 self.max_width = max_width
233 self.max_width = max_width
236 self.newline = newline
234 self.newline = newline
235 self.max_seq_length = max_seq_length
237 self.output_width = 0
236 self.output_width = 0
238 self.buffer_width = 0
237 self.buffer_width = 0
239 self.buffer = deque()
238 self.buffer = deque()
@@ -606,13 +605,13 b' def _seq_pprinter_factory(start, end, basetype):'
606 return p.text(start + '...' + end)
605 return p.text(start + '...' + end)
607 step = len(start)
606 step = len(start)
608 p.begin_group(step, start)
607 p.begin_group(step, start)
609 for idx, x in _enumerate(obj, SEQ_LENGTH_LIMIT):
608 for idx, x in _enumerate(obj, p.max_seq_length):
610 if idx:
609 if idx:
611 p.text(',')
610 p.text(',')
612 p.breakable()
611 p.breakable()
613 p.pretty(x)
612 p.pretty(x)
614
613
615 if len(obj) >= SEQ_LENGTH_LIMIT:
614 if len(obj) >= p.max_seq_length:
616 p.text(',')
615 p.text(',')
617 p.breakable()
616 p.breakable()
618 p.text('...')
617 p.text('...')
@@ -648,13 +647,13 b' def _set_pprinter_factory(start, end, basetype):'
648 except Exception:
647 except Exception:
649 # Sometimes the items don't sort.
648 # Sometimes the items don't sort.
650 pass
649 pass
651 for idx, x in _enumerate(items, SEQ_LENGTH_LIMIT):
650 for idx, x in _enumerate(items, p.max_seq_length):
652 if idx:
651 if idx:
653 p.text(',')
652 p.text(',')
654 p.breakable()
653 p.breakable()
655 p.pretty(x)
654 p.pretty(x)
656
655
657 if len(obj) >= SEQ_LENGTH_LIMIT:
656 if len(obj) >= p.max_seq_length:
658 p.text(',')
657 p.text(',')
659 p.breakable()
658 p.breakable()
660 p.text('...')
659 p.text('...')
@@ -682,7 +681,7 b' def _dict_pprinter_factory(start, end, basetype=None):'
682 except Exception as e:
681 except Exception as e:
683 # Sometimes the keys don't sort.
682 # Sometimes the keys don't sort.
684 pass
683 pass
685 for idx, key in _enumerate(keys, SEQ_LENGTH_LIMIT):
684 for idx, key in _enumerate(keys, p.max_seq_length):
686 if idx:
685 if idx:
687 p.text(',')
686 p.text(',')
688 p.breakable()
687 p.breakable()
@@ -690,7 +689,7 b' def _dict_pprinter_factory(start, end, basetype=None):'
690 p.text(': ')
689 p.text(': ')
691 p.pretty(obj[key])
690 p.pretty(obj[key])
692
691
693 if len(obj) >= SEQ_LENGTH_LIMIT:
692 if len(obj) >= p.max_seq_length:
694 p.text(',')
693 p.text(',')
695 p.breakable()
694 p.breakable()
696 p.text('...')
695 p.text('...')
General Comments 0
You need to be logged in to leave comments. Login now