def __call__(cls, *args, **kwargs): session = kwargs.pop('session', None) instance = object.__new__(cls, *args, **kwargs) instance.session = session instance.config = config.Config([]) config_section = getattr(instance, 'configSection', None) switch = getattr(instance, 'commandLineSwitch', None) if session is not None and config_section is not None: instance.config = session.get(config_section) always_on = instance.config.as_bool('always-on', default=instance.alwaysOn) instance.__init__(*args, **kwargs) if always_on: instance.register() if switch is not None: short_opt, long_opt, help = switch if always_on: # always-on plugins should hide their options help = argparse.SUPPRESS instance.addOption(instance._register_cb, short_opt, long_opt, help) return instance
def setUp(self): self.conf = config.Config([ ('a', ' 1 '), ('b', ' x\n y '), ('c', '0'), ('d', '123')])
def setUp(self): self.conf = config.Config([("a", " 1 "), ("b", " x\n y "), ("c", "0"), ("d", "123")])