##// END OF EJS Templates
Merge pull request #4561 from minrk/for_type_clear...
Merge pull request #4561 from minrk/for_type_clear Copied some of the logic from apptools (thanks @rkern). The current behavior: - `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 - `for_type(type_or_str)` - behaves the same, only adding support for type strings for consistency - `pop(type_or_str[, default])` - remove a type (by type or string) - `typ_or_str in Formatter` checks whether a type is registered, checking with `lookup_by_type` The inner structures remain unchanged.

File last commit:

r13789:68df9a45
r13976:3db536e9 merge
Show More
formatters.txt
20 lines | 845 B | text/plain | TextLexer
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
- ``pop(type_or_str)`` - remove a type (by type or string).
Pass a second argument to avoid KeyError (like dict).
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.