def unload_component(self, component): """Unload a component. This method does a sanity check if the applied object is a component and fails sliently if the component is not loaded. :param component: A component class to unload. :return: Either `True` or `False` specifying whether the component was unloaded or not. """ logger.debug(u"Unload component %r" % component) isinterface = getattr(component, "_isinterface", False) if isinterface and component in self._components: self._components.pop(component) return True return False
def unload_component(self, component): """Unload a component. This method does a sanity check if the applied object is a component and fails sliently if the component is not loaded. :param component: A component class to unload. :return: Either `True` or `False` specifying whether the component was unloaded or not. """ logger.debug(u'Unload component %r' % component) isinterface = getattr(component, '_isinterface', False) if isinterface and component in self._components: self._components.pop(component) return True return False
def load_component(self, component): """Load a component. This method doesn't care whether the component is activated or not. If you manually load a component it will always load, use :meth:`~ApplicationContext.load_packages` if you don't want this behaviour. :param component: A component object. This must be an an implementation not an interface to get loaded. """ logger.debug(u"Load component %r" % component) try: for interface in component._interfaces: self._components.setdefault(interface, set()).add(component) except (AttributeError, TypeError): # fail silently if we try to register an interface but raise # if there's something completely wrong if not hasattr(component, "_isinterface"): raise RuntimeError(u"Type %r is not a component" % component) else: return component
def load_component(self, component): """Load a component. This method doesn't care whether the component is activated or not. If you manually load a component it will always load, use :meth:`~ApplicationContext.load_packages` if you don't want this behaviour. :param component: A component object. This must be an an implementation not an interface to get loaded. """ logger.debug(u'Load component %r' % component) try: for interface in component._interfaces: self._components.setdefault(interface, set()).add(component) except (AttributeError, TypeError): # fail silently if we try to register an interface but raise # if there's something completely wrong if not hasattr(component, '_isinterface'): raise RuntimeError(u'Type %r is not a component' % component) else: return component
def log(self): """Logs the email""" logger.debug('%s\n%s\n\n' % ('-' * 79, self.format('\n').rstrip())) if ctx.cfg['testing']: outbox.append(self.as_message().as_string())