def getFilter(self, option, default=noDefault, negate=False, filterParser=str, filterStr=str.__str__, defaultMatcher='start', defaultFilter='strict', defaultOrder=ListOrder.source, **kwargs): matcherOpt = appendOption(option, 'matcher') matcherObj = self.getPlugin(matcherOpt, defaultMatcher, cls=Matcher, pargs=(matcherOpt, ), pkwargs=kwargs) filterExpr = self.get(option, default, str2obj=filterParser, obj2str=filterStr, **kwargs) filterOrder = self.getEnum(appendOption(option, 'order'), ListOrder, defaultOrder, **kwargs) return self.getPlugin(appendOption(option, 'plugin'), defaultFilter, cls=ListFilter, pargs=(filterExpr, matcherObj, filterOrder, negate), **kwargs)
def getFilter(self, option, default = noDefault, matchKey = None, negate = False, filterParser = str, filterStr = str.__str__, defaultMatcher = 'start', defaultFilter = 'strict', defaultOrder = ListOrder.source, **kwargs): matcherOpt = appendOption(option, 'matcher') matcherObj = self.getPlugin(matcherOpt, defaultMatcher, cls = Matcher, pargs = (matcherOpt,)) filterExpr = self.get(option, default, str2obj = filterParser, obj2str = filterStr, **kwargs) filterOrder = self.getEnum(appendOption(option, 'order'), ListOrder, defaultOrder) return self.getPlugin(appendOption(option, 'plugin'), defaultFilter, cls = ListFilter, pargs = (filterExpr, matcherObj, filterOrder, matchKey, negate))
def getFilter(self, option, default = noDefault, defaultMatcher = 'start', defaultFilter = 'strict', defaultOrder = ListOrder.source, **kwargs): matcherOpt = appendOption(option, 'matcher') matcherObj = self.getPlugin(matcherOpt, defaultMatcher, cls = Matcher, pargs = (matcherOpt,)) filterExpr = self.get(option, default, **kwargs) filterOrder = self.getEnum(appendOption(option, 'order'), ListOrder, defaultOrder) return self.getPlugin(appendOption(option, 'filter'), defaultFilter, cls = ListFilter, pargs = (filterExpr, matcherObj, filterOrder))
def __init__(self, config, option_prefix): Matcher.__init__(self, config, option_prefix) self._baseMatcher = config.getPlugin(appendOption( option_prefix, 'mode'), 'start', cls=Matcher, pargs=(option_prefix))
def __init__(self, config, option_prefix, case_override = None, **kwargs): ConfigurablePlugin.__init__(self, config) self._case = case_override if case_override is None: self._case = config.getBool(appendOption(option_prefix, 'case sensitive'), default = True, **kwargs) self._log = logging.getLogger('matcher.%s' % option_prefix) if not self._log.isEnabledFor(logging.DEBUG1): self._log = None
def getLookup(self, option, default = noDefault, defaultMatcher = 'start', single = True, includeDefault = False, **kwargs): matcherArgs = {} if 'onChange' in kwargs: matcherArgs['onChange'] = kwargs['onChange'] matcherOpt = appendOption(option, 'matcher') matcherObj = self.getPlugin(matcherOpt, defaultMatcher, cls = Matcher, pargs = (matcherOpt,), **matcherArgs) (sourceDict, sourceOrder) = self.getDict(option, default, **kwargs) return DictLookup(sourceDict, sourceOrder, matcherObj, single, includeDefault)
def __init__(self, config, option_prefix, case_override=None, **kwargs): Matcher.__init__(self, config, option_prefix, case_override, **kwargs) self._baseMatcher = config.getPlugin(appendOption( option_prefix, 'mode'), 'start', cls=Matcher, pargs=(option_prefix, self._case), pkwargs=kwargs, **kwargs)
def getLookup(self, option, default = noDefault, defaultMatcher = 'start', single = True, includeDefault = False, **kwargs): matcherArgs = {} if 'onChange' in kwargs: matcherArgs['onChange'] = kwargs['onChange'] matcherOpt = appendOption(option, 'matcher') matcherObj = self.getPlugin(matcherOpt, defaultMatcher, cls = Matcher, pargs = (matcherOpt,), **matcherArgs) (sourceDict, sourceOrder) = self.getDict(option, default, **kwargs) return DictLookup(sourceDict, sourceOrder, matcherObj, single, includeDefault)
def __init__(self, config, option_prefix, case_override=None, **kwargs): ConfigurablePlugin.__init__(self, config) self._case = case_override if case_override is None: self._case = config.getBool(appendOption(option_prefix, 'case sensitive'), default=True, **kwargs) self._log = logging.getLogger('matcher.%s' % option_prefix) if not self._log.isEnabledFor(logging.DEBUG1): self._log = None
def isInteractive(self, option, default): if isinstance(option, list): user_option_exists = any(imap(lambda opt: opt in self.getOptions(), option)) else: user_option_exists = option in self.getOptions() # global switch to enable / disable interactive option queries config_interactive = self.changeView(interfaceClass = TypedConfigInterface, viewClass = SimpleConfigView, setSections = ['interactive']) if self._interactive_enabled is None: self._interactive_enabled = config_interactive.getBool('default', True, onChange = None) icfg = config_interactive.getBool(appendOption(option, 'interactive'), self._interactive_enabled and default, onChange = None) return icfg and not user_option_exists
def getCompositePlugin(self, option, default = noDefault, default_compositor = noDefault, option_compositor = None, cls = Plugin, tags = None, inherit = False, requirePlugin = True, pargs = None, pkwargs = None, **kwargs): clsList = [] for factory in self._getPluginFactories(option, default, cls, tags, inherit, requirePlugin, singlePlugin = False, desc = 'composite plugin', **kwargs): clsList.append(factory.getBoundInstance(*(pargs or ()), **(pkwargs or {}))) if len(clsList) == 1: return clsList[0] elif not clsList: # requirePlugin == False return None if not option_compositor: option_compositor = appendOption(option, 'manager') return self.getPlugin(option_compositor, default_compositor, cls, tags, inherit, pargs = tuple([clsList] + list(pargs or [])), **kwargs)
def getCompositePlugin(self, option, default = noDefault, default_compositor = noDefault, option_compositor = None, cls = Plugin, tags = None, inherit = False, requirePlugin = True, pargs = None, pkwargs = None, **kwargs): clsList = [] for factory in self._getPluginFactories(option, default, cls, tags, inherit, requirePlugin, singlePlugin = False, desc = 'composite plugin', **kwargs): clsList.append(factory.getBoundInstance(*(pargs or ()), **(pkwargs or {}))) if len(clsList) == 1: return clsList[0] elif not clsList: # requirePlugin == False return None if not option_compositor: option_compositor = appendOption(option, 'manager') return self.getPlugin(option_compositor, default_compositor, cls, tags, inherit, pargs = tuple([clsList] + list(pargs or [])), **kwargs)
def isInteractive(self, option, default): if isinstance(option, list): user_option_exists = any( imap(lambda opt: opt in self.getOptions(), option)) else: user_option_exists = option in self.getOptions() # global switch to enable / disable interactive option queries config_interactive = self.changeView( interfaceClass=TypedConfigInterface, viewClass=SimpleConfigView, setSections=['interactive']) if self._interactive_enabled is None: self._interactive_enabled = config_interactive.getBool( 'default', True, onChange=None) icfg = config_interactive.getBool(appendOption(option, 'interactive'), self._interactive_enabled and default, onChange=None) return icfg and not user_option_exists
def getMatcher(self, option, default=noDefault, defaultMatcher='start', negate=False, filterParser=str, filterStr=str.__str__, **kwargs): matcherOpt = appendOption(option, 'matcher') matcherObj = self.getPlugin(matcherOpt, defaultMatcher, cls=Matcher, pargs=(matcherOpt, ), pkwargs=kwargs) filterExpr = self.get(option, default, str2obj=filterParser, obj2str=filterStr, **kwargs) return matcherObj.matchWith(filterExpr)
def __init__(self, config, option_prefix, *kwargs): ConfigurablePlugin.__init__(self, config) self._case = config.getBool(appendOption(option_prefix, 'case sensitive'), default = True)
def __init__(self, config, option_prefix): Matcher.__init__(self, config, option_prefix) self._baseMatcher = config.getPlugin(appendOption(option_prefix, 'mode'), 'start', cls = Matcher, pargs = (option_prefix))
def getMatcher(self, option, default = noDefault, defaultMatcher = 'start', negate = False, filterParser = str, filterStr = str.__str__, **kwargs): matcherOpt = appendOption(option, 'matcher') matcherObj = self.getPlugin(matcherOpt, defaultMatcher, cls = Matcher, pargs = (matcherOpt,), pkwargs = kwargs) filterExpr = self.get(option, default, str2obj = filterParser, obj2str = filterStr, **kwargs) return matcherObj.matchWith(filterExpr)
def getCommand(self, option, default=noDefault, **kwargs): scriptType = self.getEnum(appendOption(option, 'type'), CommandType, CommandType.executable, **kwargs) if scriptType == CommandType.executable: return self.getPath(option, default, **kwargs) return os.path.expandvars(self.get(option, default, **kwargs))
def __init__(self, config, option_prefix, case_override = None, **kwargs): Matcher.__init__(self, config, option_prefix, case_override, **kwargs) self._baseMatcher = config.getPlugin(appendOption(option_prefix, 'mode'), 'start', cls = Matcher, pargs = (option_prefix, self._case), pkwargs = kwargs, **kwargs)
def __init__(self, config, option_prefix, *kwargs): ConfigurablePlugin.__init__(self, config) self._case = config.getBool(appendOption(option_prefix, 'case sensitive'), default=True)
def getCommand(self, option, default = noDefault, **kwargs): scriptType = self.getEnum(appendOption(option, 'type'), CommandType, CommandType.executable, **kwargs) if scriptType == CommandType.executable: return self.getPath(option, default, **kwargs) return os.path.expandvars(self.get(option, default, **kwargs))