def register_pretty(type=None, predicate=None):
if type is None and predicate is None:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>if type is not None and predicate is not None:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>if predicate is not None:<EOL><INDENT>if not callable(predicate):<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>".format(<EOL>repr(predicate)<EOL>)<EOL>)<EOL><DEDENT><DEDENT>def decorator(fn):<EOL><INDENT>sig = inspect.signature(fn)<EOL>value = None<EOL>ctx = None<EOL>try:<EOL><INDENT>sig.bind(value, ctx)<EOL><DEDENT>except TypeError:<EOL><INDENT>fnname = '<STR_LIT>'.format(<EOL>fn.__module__,<EOL>fn.__qualname__<EOL>)<EOL>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(<EOL>fnname<EOL>)<EOL>)<EOL><DEDENT>if type:<EOL><INDENT>if isinstance(type, str):<EOL><INDENT>_DEFERRED_DISPATCH_BY_NAME[type] = fn<EOL><DEDENT>else:<EOL><INDENT>pretty_dispatch.register(type, partial(_run_pretty, fn))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>assert callable(predicate)<EOL>_PREDICATE_REGISTRY.append((predicate, fn))<EOL><DEDENT>return fn<EOL><DEDENT>return decorator<EOL>
Returns a decorator that registers the decorated function
    as the pretty printer for instances of ``type``.

    :param type: the type to register the pretty printer for, or a ``str``
                 to indicate the module and name, e.g.: ``'collections.Counter'``.
    :param predicate: a predicate function that takes one argument
                      and returns a boolean indicating if the value
                      should be handled by the registered pretty printer.

    Only one of ``type`` and ``predicate`` may be supplied. That means
    that ``predicate`` will be run on unregistered types only.

    The decorated function must accept exactly two positional arguments:

    - ``value`` to pretty print, and
    - ``ctx``, a context value.

    Here's an example of the pretty printer for OrderedDict:

    .. code:: python

        from collections import OrderedDict
        from prettyprinter import register_pretty, pretty_call

        @register_pretty(OrderedDict)
        def pretty_orderreddict(value, ctx):
            return pretty_call(ctx, OrderedDict, list(value.items()))