Beispiel #1
0
class TraitInspector(metaclass=Singleton):
    """ Trait specific implementation of Inspector.

    This class is extension to general purpose Inspector. While original
    inspector gives string as a result of inspection, this class provides
    whole class (a.k.a Primitive) to caller. These primitives then provide
    special functionality for given object type.

    This class acts also as a singleton.
    """
    def __init__(self):
        self.__inspector = Inspector()

    def __call__(self, object):
        return self.__inspector.inspect(object)

    @classmethod
    def add_hook(cls, name, hook):
        cls().__inspector.add_hook(name, hook)

    @classmethod
    def add_default_hook(cls, hook):
        cls().__inspector.add_default_hook(hook)
Beispiel #2
0
 def __init__(self):
     self.__inspector = Inspector()