Пример #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)
Пример #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
Пример #3
0
Файл: views.py Проект: 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