Exemplo n.º 1
0
def validate_by_spec(error_list):
    try:
        # Generate the spec file
        configspec = generate_configspec()
        config_dir = os.getenv("HUE_CONF_DIR", get_desktop_root("conf"))
        # Load the .ini files
        conf = load_confs(configspec.name, _configs_from_dir(config_dir))
        # Validate after merging all the confs
        collect_validation_messages(conf, error_list)
    finally:
        os.remove(configspec.name)
Exemplo n.º 2
0
def load_confs(configspecpath, conf_source=None):
  """Loads and merges all of the configurations passed in,
  returning a ConfigObj for the result.

  @param conf_source if not specified, reads conf/ from desktop/conf/. Otherwise should be a generator of ConfigObjs
  """
  if conf_source is None:
    conf_source = _configs_from_dir(get_desktop_root("conf"))

  conf = ConfigObj(configspec=configspecpath)
  for in_conf in conf_source:
    conf.merge(in_conf)
  return conf
Exemplo n.º 3
0
Arquivo: views.py Projeto: uk0/hue
def load_confs(configspecpath):
  conf_source = _configs_from_dir(get_desktop_root("conf"))
  conf = ConfigObj(configspec=configspecpath)
  for in_conf in conf_source:
    conf.merge(in_conf)
  return conf