##// END OF EJS Templates
Update IPython/core/formatters.py to use new traitlets API....
Matthias Bussonnier -
Show More
@@ -11,7 +11,6 b' Inheritance diagram:'
11 # Distributed under the terms of the Modified BSD License.
11 # Distributed under the terms of the Modified BSD License.
12
12
13 import abc
13 import abc
14 import inspect
15 import json
14 import json
16 import sys
15 import sys
17 import traceback
16 import traceback
@@ -36,7 +35,7 b' from IPython.utils.py3compat import ('
36 class DisplayFormatter(Configurable):
35 class DisplayFormatter(Configurable):
37
36
38 # When set to true only the default plain text formatter will be used.
37 # When set to true only the default plain text formatter will be used.
39 plain_text_only = Bool(False, config=True)
38 plain_text_only = Bool(False).tag(config=True)
40 def _plain_text_only_changed(self, name, old, new):
39 def _plain_text_only_changed(self, name, old, new):
41 warnings.warn("""DisplayFormatter.plain_text_only is deprecated.
40 warnings.warn("""DisplayFormatter.plain_text_only is deprecated.
42
41
@@ -50,7 +49,7 b' class DisplayFormatter(Configurable):'
50 else:
49 else:
51 self.active_types = self.format_types
50 self.active_types = self.format_types
52
51
53 active_types = List(Unicode(), config=True,
52 active_types = List(Unicode()).tag(config=True,
54 help="""List of currently active mime-types to display.
53 help="""List of currently active mime-types to display.
55 You can use this to set a white-list for formats to display.
54 You can use this to set a white-list for formats to display.
56
55
@@ -288,21 +287,21 b' class BaseFormatter(Configurable):'
288 format_type = Unicode('text/plain')
287 format_type = Unicode('text/plain')
289 _return_type = string_types
288 _return_type = string_types
290
289
291 enabled = Bool(True, config=True)
290 enabled = Bool(True).tag(config=True)
292
291
293 print_method = ObjectName('__repr__')
292 print_method = ObjectName('__repr__')
294
293
295 # The singleton printers.
294 # The singleton printers.
296 # Maps the IDs of the builtin singleton objects to the format functions.
295 # Maps the IDs of the builtin singleton objects to the format functions.
297 singleton_printers = Dict(config=True)
296 singleton_printers = Dict().tag(config=True)
298
297
299 # The type-specific printers.
298 # The type-specific printers.
300 # Map type objects to the format functions.
299 # Map type objects to the format functions.
301 type_printers = Dict(config=True)
300 type_printers = Dict().tag(config=True)
302
301
303 # The deferred-import type-specific printers.
302 # The deferred-import type-specific printers.
304 # Map (modulename, classname) pairs to the format functions.
303 # Map (modulename, classname) pairs to the format functions.
305 deferred_printers = Dict(config=True)
304 deferred_printers = Dict().tag(config=True)
306
305
307 @catch_format_error
306 @catch_format_error
308 def __call__(self, obj):
307 def __call__(self, obj):
@@ -569,9 +568,9 b' class PlainTextFormatter(BaseFormatter):'
569
568
570 # This subclass ignores this attribute as it always need to return
569 # This subclass ignores this attribute as it always need to return
571 # something.
570 # something.
572 enabled = Bool(True, config=False)
571 enabled = Bool(True).tag(config=False)
573
572
574 max_seq_length = Integer(pretty.MAX_SEQ_LENGTH, config=True,
573 max_seq_length = Integer(pretty.MAX_SEQ_LENGTH).tag(config=True,
575 help="""Truncate large collections (lists, dicts, tuples, sets) to this size.
574 help="""Truncate large collections (lists, dicts, tuples, sets) to this size.
576
575
577 Set to 0 to disable truncation.
576 Set to 0 to disable truncation.
@@ -582,21 +581,21 b' class PlainTextFormatter(BaseFormatter):'
582 print_method = ObjectName('_repr_pretty_')
581 print_method = ObjectName('_repr_pretty_')
583
582
584 # Whether to pretty-print or not.
583 # Whether to pretty-print or not.
585 pprint = Bool(True, config=True)
584 pprint = Bool(True).tag(config=True)
586
585
587 # Whether to be verbose or not.
586 # Whether to be verbose or not.
588 verbose = Bool(False, config=True)
587 verbose = Bool(False).tag(config=True)
589
588
590 # The maximum width.
589 # The maximum width.
591 max_width = Integer(79, config=True)
590 max_width = Integer(79).tag(config=True)
592
591
593 # The newline character.
592 # The newline character.
594 newline = Unicode('\n', config=True)
593 newline = Unicode('\n').tag(config=True)
595
594
596 # format-string for pprinting floats
595 # format-string for pprinting floats
597 float_format = Unicode('%r')
596 float_format = Unicode('%r')
598 # setter for float precision, either int or direct format-string
597 # setter for float precision, either int or direct format-string
599 float_precision = CUnicode('', config=True)
598 float_precision = CUnicode('').tag(config=True)
600
599
601 def _float_precision_changed(self, name, old, new):
600 def _float_precision_changed(self, name, old, new):
602 """float_precision changed, set float_format accordingly.
601 """float_precision changed, set float_format accordingly.
General Comments 0
You need to be logged in to leave comments. Login now