def confIfPipelineConfigSet(conf, options): """ Takes a conf, checks to see if a pipeline conf file is specified, if so it loads it up and applies it OVER any options specified on the command line. This may seem counter intuitive but it makes other things easier, for example a pipeline redefining anything in the machines.conf since that is also in this conf. It then applies the functions in the OPTIONS variable in the values in the config file """ if conf('CONFIG_FILE', default=None) is not None: fconf = config.configFromStream(open(conf('CONFIG_FILE'))) keys = fconf.keys() m = {} for o in options: ## # Get the name of the option, it's the first element of the tuple name = o[0] f = o[4] if name in keys: m[name] = applyIfCallable(f(fconf(name)), conf) ## # lazy=True is for saftey incase there is a value in the CONFIG_FILE that we use that # really depends on a value in the map we just created return config.configFromMap( m, config.configFromStream(open(conf('CONFIG_FILE')), conf, lazy=False)) else: return conf
def confIfPipelineConfigSet(conf, options): """ Takes a conf, checks to see if a pipeline conf file is specified, if so it loads it up and applies it OVER any options specified on the command line. This may seem counter intuitive but it makes other things easier, for example a pipeline redefining anything in the machines.conf since that is also in this conf. It then applies the functions in the OPTIONS variable in the values in the config file """ if conf("CONFIG_FILE", default=None) is not None: fconf = config.configFromStream(open(conf("CONFIG_FILE"))) keys = fconf.keys() m = {} for o in options: ## # Get the name of the option, it's the first element of the tuple name = o[0] f = o[4] if name in keys: m[name] = applyIfCallable(f(fconf(name)), conf) ## # lazy=True is for saftey incase there is a value in the CONFIG_FILE that we use that # really depends on a value in the map we just created return config.configFromMap(m, config.configFromStream(open(conf("CONFIG_FILE")), conf, lazy=False)) else: return conf
def c(conf): val = x for f in funcs: val = f(val) try: val = replaceStr(val, conf) except TypeError: pass val = applyIfCallable(val, conf) try: return replaceStr(val, conf) except TypeError: return val
def applyOption(val, option, conf): try: # # We want to apply any replacements on the options # The question is if baseConf is really the config file # we should be applying these from... v = option[4](val) # # Now v might still be a function at this point because we want to give # them the ability to access baseConf is they need it to do more replacements v = applyIfCallable(v, conf) try: return replaceStr(v, conf) except TypeError: return v except MissingOptionError, err: raise CLIError(option[0], err)