formatters.txt
20 lines
| 845 B
| text/plain
|
TextLexer
MinRK
|
r13785 | DisplayFormatter changes | ||
======================== | ||||
There was no official way to query or remove callbacks in the Formatter API. | ||||
To remedy this, the following methods are added to :class:`BaseFormatter`: | ||||
- ``lookup(instance)`` - return appropriate callback or a given object | ||||
- ``lookup_by_type(type_or_str)`` - return appropriate callback for a given type or ``'mod.name'`` type string | ||||
MinRK
|
r13789 | - ``pop(type_or_str)`` - remove a type (by type or string). | ||
Pass a second argument to avoid KeyError (like dict). | ||||
MinRK
|
r13785 | |||
All of the above methods raise a KeyError if no match is found. | ||||
And the following methods are changed: | ||||
- ``for_type(type_or_str)`` - behaves the same as before, only adding support for ``'mod.name'`` | ||||
type strings in addition to plain types. This removes the need for ``for_type_by_name()``, | ||||
but it remains for backward compatibility. | ||||