Esempio n. 1
0
 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))
Esempio n. 3
0
	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))
Esempio n. 4
0
 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))
Esempio n. 5
0
	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
Esempio n. 6
0
	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)
Esempio n. 7
0
 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)
Esempio n. 9
0
 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
Esempio n. 10
0
	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)
Esempio n. 12
0
	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)
Esempio n. 13
0
 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
Esempio n. 14
0
 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)
Esempio n. 15
0
	def __init__(self, config, option_prefix, *kwargs):
		ConfigurablePlugin.__init__(self, config)
		self._case = config.getBool(appendOption(option_prefix, 'case sensitive'), default = True)
Esempio n. 16
0
	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))
Esempio n. 17
0
	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)
Esempio n. 18
0
 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))
Esempio n. 19
0
	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)
Esempio n. 20
0
 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))