def adapts(from_, to, extra=None, factory=None, cached=False, when=''):

    from traits.adaptation.api import register_factory
    from traits.adaptation.cached_adapter_factory import CachedAdapterFactory
    from traits.protocols.advice import addClassAdvisor

    if extra is not None:
        adapter, from_, to = from_, to, extra
    else:
        adapter = None

    @deprecated("use the 'register_factory' function from 'traits.api' instead")
    def callback(klass):
        """ Called when the class has been created. """

        # At this point:-
        #
        # klass is the callable (usually a class) that takes one argument (the
        # adaptee) and returns an appropriate adapter (or None if the adaptation
        # is not possible).

        # What the adapters created by the factory will adapt from.
        if type(from_) is not list:
            from_protocols = [from_]

        else:
            from_protocols = from_

        # What the adapters created by the factory will adapt to.
        if type(to) is not list:
            to_protocols = [to]

        else:
            to_protocols = to

        if factory is None:
            # If the adapter is cached or has a 'when' expression then create a
            # default factory:

            adapter_factory = klass

            if when != '':
                def _conditional_factory(adaptee, *args, **kw):
                    namespace = {'adaptee': adaptee}

                    if eval(when, namespace, namespace):
                        return klass(adaptee, *args, **kw)

                    return None

                adapter_factory = _conditional_factory

            if cached:
                adapter_factory = CachedAdapterFactory(factory=adapter_factory)

        else:
            adapter_factory = factory

        for from_protocol in from_protocols:
            for to_protocol in to_protocols:
                register_factory(adapter_factory, from_protocol, to_protocol)

        for to_protocol in to_protocols:
            # We cannot register adapter factories that are functions. (This is
            # ony relevant when using 'adapts' as a function.
            if isinstance(klass, type):
                # We use type(to_protocol) in case the to_protocols implements
                # its own 'register' method which overrides the ABC method.
                type(to_protocol).register(to_protocol, klass)

        return klass

    if adapter is not None:
        callback(adapter)

    else:
        addClassAdvisor(callback)

#### EOF ######################################################################
Store a current summary in self.summaries.
dataset/ETHPy150Open enthought/traits/traits/adaptation/adapter.py/adapts--crossover with--dataset/ETHPy150Open pympler/pympler/pympler/tracker.py/SummaryTracker.store_summary