def __init__(self, config, name): self._name = name # needed for changeView calls before the constructor head = [('DATASETNICK', 'Nickname')] # Mapping between nickname and config files: self._nmCfg = config.getLookup('nickname config', {}, defaultMatcher = 'regex', parser = lambda x: lmap(str.strip, x.split(',')), strfun = lambda x: str.join(',', x)) if not self._nmCfg.empty(): allConfigFiles = sorted(set(ichain(self._nmCfg.get_values()))) config.set('config file', str.join('\n', allConfigFiles)) head.append((1, 'Config file')) elif config.get('config file', ''): raise ConfigError("Please use 'nickname config' instead of 'config file'") # Mapping between nickname and constants - only display - work is handled by the 'normal' parameter factory nmCName = config.getList('nickname constants', [], onChange = None) param_config = config.changeView(viewClass = 'TaggedConfigView', setClasses = None, setNames = None, addSections = ['parameters']) param_config.set('constants', str.join(' ', nmCName), '+=') for cName in nmCName: param_config.set(cName + ' matcher', 'regex') param_config.set(cName + ' lookup', 'DATASETNICK') head.append((cName, cName)) # Mapping between nickname and lumi filter - only display - work is handled by the 'normal' lumi filter config.set('lumi filter matcher', 'regex') if 'nickname lumi filter' in config.getOptions(): config.set('lumi filter', strDictLong(config.getDict('nickname lumi filter', {}, onChange = None))) self._nmLumi = config.getLookup('lumi filter', {}, parser = parseLumiFilter, strfun = strLumi, onChange = None) if not self._nmLumi.empty(): head.append((2, 'Lumi filter')) CMSSW.__init__(self, config, name) self._displaySetup(config.getWorkPath('datacache.dat'), head)
def getDict(self, option, default=noDefault, parser=identity, strfun=str, **kwargs): obj2str = lambda value: strDictLong(value, parser, strfun) str2obj = lambda value: parseDict(value, parser) def2obj = lambda value: ( value, sorted(ifilter(lambda key: key is not None, value.keys()))) return self._getInternal('dictionary', obj2str, str2obj, def2obj, option, default, **kwargs)
def __init__(self, config, name): self._name = name # needed for changeView calls before the constructor head = [('DATASETNICK', 'Nickname')] # Mapping between nickname and config files: self._nmCfg = config.getLookup( 'nickname config', {}, defaultMatcher='regex', parser=lambda x: lmap(str.strip, x.split(',')), strfun=lambda x: str.join(',', x)) if not self._nmCfg.empty(): if 'config file' in config.getOptions(): raise ConfigError( "Please use 'nickname config' instead of 'config file'") allConfigFiles = sorted( set(utils.flatten(self._nmCfg.get_values()))) config.set('config file', str.join('\n', allConfigFiles)) head.append((1, 'Config file')) # Mapping between nickname and constants - only display - work is handled by the 'normal' parameter factory nmCName = config.getList('nickname constants', [], onChange=None) param_config = config.changeView(viewClass='TaggedConfigView', setClasses=None, setNames=None, addSections=['parameters']) param_config.set('constants', str.join(' ', nmCName), '+=') for cName in nmCName: param_config.set(cName + ' matcher', 'regex') param_config.set(cName + ' lookup', 'DATASETNICK') head.append((cName, cName)) # Mapping between nickname and lumi filter - only display - work is handled by the 'normal' lumi filter if ('lumi filter' in config.getOptions()) and ('nickname lumi filter' in config.getOptions()): raise ConfigError('Please use "lumi filter" exclusively') config.set('lumi filter matcher', 'regex') config.set( 'lumi filter', strDictLong( config.getDict('nickname lumi filter', {}, onChange=None))) self._nmLumi = config.getLookup('lumi filter', {}, parser=parseLumiFilter, strfun=strLumi, onChange=None) if not self._nmLumi.empty(): head.append((2, 'Lumi filter')) CMSSW.__init__(self, config, name) self._displaySetup(config.getWorkPath('datacache.dat'), head)
def getDict(self, option, default = noDefault, parser = identity, strfun = str, **kwargs): obj2str = lambda value: strDictLong(value, parser, strfun) str2obj = lambda value: parseDict(value, parser) def2obj = lambda value: (value, sorted(ifilter(lambda key: key is not None, value.keys()))) return self._getInternal('dictionary', obj2str, str2obj, def2obj, option, default, **kwargs)