Ejemplo n.º 1
0
    def __init__(cls, what, bases=None, dict=None):
        super(AdapterMeta, cls).__init__(what, bases, dict)

        if not is_abstract(cls):
            for protocol in getattr(cls, 'supported_protocols', ()):
                # Note that we will not overwrite existing registered adapters.
                adapter_registry.setdefault(protocol, cls)
Ejemplo n.º 2
0
    def __init__(cls, what, bases=None, dict=None):
        super(CommandMeta, cls).__init__(what, bases, dict)

        if not is_abstract(cls):
            command = getattr(cls, 'command')
            if command:
                command_registry[command] = cls
Ejemplo n.º 3
0
  def __init__(cls, what, bases=None, dict=None):
    super(AdapterMeta, cls).__init__(what, bases, dict)

    if not is_abstract(cls):
      for protocol in getattr(cls, 'supported_protocols', ()):
        # Note that we will not overwrite existing registered adapters.
        adapter_registry.setdefault(protocol, cls)
Ejemplo n.º 4
0
  def __init__(cls, what, bases=None, dict=None):
    super(CommandMeta, cls).__init__(what, bases, dict)

    if not is_abstract(cls):
      command = getattr(cls, 'command')
      if command:
        command_registry[command] = cls
Ejemplo n.º 5
0
def is_filter_type(target: typing.Any) -> typing.Union[bool, str]:
    """
    Returns whether the specified object can be registered as a filter.

    :return:
        Returns ``True`` if the object is a filter.
        Otherwise, returns a string indicating why it is not valid.
    """
    if not is_class(target):
        return 'not a class'

    if not issubclass(target, BaseFilter):
        return 'does not extend BaseFilter'

    if is_abstract(target):
        return 'abstract class'

    return True
Ejemplo n.º 6
0
        def __init__(self, cls_name, bases, attrs):
            super(_metaclass, self) \
                .__init__(cls_name, bases, attrs)

            if not is_abstract(self):
                tag_registry.register(self)
Ejemplo n.º 7
0
        def __init__(self, what, bases=None, attrs=None):
            super(_metaclass, self).__init__(what, bases, attrs)

            if not is_abstract(self):
                registry.register(self)