Convert current configuration to YAML format

@param config map
@return yaml string
@throws IOException error
175072
public static String toYAML(Map<String, ? extends CacheConfig> config) throws IOException {
        return new CacheConfigSupport().toYAML(config);
    }
1116263
protected <T> T map(Config config, Class<T> clazz) {
    return map(config, null, null, clazz);
  }
689480
@SuppressWarnings("unchecked")
    @Override
    public T readConfig(String filePath) throws ConfigurationException {
        try {
            YamlReader reader = new YamlReader(new FileReader(filePath));
            reader.getConfig().setClassTag(clazz.getSimpleName(), clazz);
            return (T) reader.read();
        } catch (FileNotFoundException e) {
            throw new ConfigurationException("Configuration Exception", "CONF_001", e);
        } catch (YamlException e) {
            throw new ConfigurationException("Configuration Exception", "CONF_002", e);
        }
    }
163272
def yaml(self):
        
        if self._yaml_adapter is None:
            self._yaml_adapter = ConfigPersistenceAdapter(
                config=self,
                reader_writer=YamlReaderWriter(),
            )
        return self._yaml_adapter
240470
private static Map<String, String[]> getSynonyms(InputStream config) throws IOException
   {
      try
      {
         Map<String, String[]> synonyms = new HashMap<String, String[]>();
         Properties props = new Properties();
         props.load(config);
         Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator();
         while (it.hasNext())
         {
            Map.Entry<Object, Object> e = it.next();
            String key = (String)e.getKey();
            String value = (String)e.getValue();
            addSynonym(key, value, synonyms);
            addSynonym(value, key, synonyms);
         }
         return synonyms;
      }
      catch (Exception e)
      {
         throw Util.createIOException(e);
      }
   }
1098186
public static Configuration loadFromString(String config)
    throws IOException, SAXException {
    ConfigurationImpl cfg = new ConfigurationImpl();

    XMLReader parser = XMLReaderFactory.createXMLReader();
    parser.setContentHandler(new ConfigHandler(cfg, null));
    Reader reader = new StringReader(config);
    parser.parse(new InputSource(reader));
    return cfg;
  }
98795
def get_config():
    
    p = Path('.travis.yml')
    if not p.exists():
        return {}
    with p.open() as f:
        travis_config = yaml.safe_load(f.read())

    config = travis_config.get('doctr', {})

    if not isinstance(config, dict):
        raise ValueError('config is not a dict: {}'.format(config))
    return config
102711
def load_configuration(yaml: yaml.ruamel.yaml.YAML, filename: str) -> DictLike:
    
    with open(filename, "r") as f:
        config = yaml.load(f)

    return config
1173676
def find_and_parse_config(config, default_config='default.yaml'):
    

    def load_config(path):
        if os.path.isfile(path):
            with open(path, 'r') as f:
                config_dict_ = yaml.load(f)
            return config_dict_

    config_path = find_file(config)
    default_path = find_file(default_config)
    config = load_config(config_path)
    default_config = load_config(default_path)
    if config is None and default_config is None:
        raise ValueError('Both config and default_config return None')
    if config is None:
        config_dict = default_config
    elif default_config is None:
        config_dict = config
    else:
        config_dict = merge(default_config, config)

    return config_dict
785948
def format_config_for_editing(data):
    """"""
    return yaml.safe_dump(data, default_flow_style=False, encoding=None, allow_unicode=True)
233788
function loadYAMLConfig(configPath) {
  try {
    return safeLoad(readFileSync(configPath, 'utf8'))
  } catch (e) {
    if (e.constructor.name === 'YAMLException') {
      throw e
    }
    log.error({
      message: chalk.red(`Unable to find YML config at "${configPath}".`),
      ref: 'unable-to-find-config',
    })
    return undefined
  }
}
859073
public static Config fromYAML(Reader reader) throws IOException {
        ConfigSupport support = new ConfigSupport();
        return support.fromYAML(reader, Config.class);
    }
1200492
public OptionsBuilder configurationFormat(String configurationFormat){
		String aux = configurationFormat.toLowerCase().trim();
		if(aux.equals("yaml") || aux.equals("json")){
			aux = "yml";
		}
		if (aux.equals("xml") || aux.equals("yml")) {
			options.put(Options.CONFIGURATION_FILE_FORMAT, aux);
		} else {
			throw new IllegalArgumentException("The configuration format "+aux+" is not supported");
		}
		return this;
	}
293648
public static void toStream(final HttpConfig config, final OutputStream ostream) {
        toStream(config, ContentTypes.ANY.getAt(0), ostream);
    }
204358
public static Map<String, String> getMandatoryConfig(
      Configuration config, List<String> keys)
      throws IOException {
    List<String> missingKeys = new ArrayList<>();
    Map<String, String> values = new HashMap<>();
    for (String key : keys) {
      String value = config.get(key);
      if (Strings.isNullOrEmpty(value)) {
        missingKeys.add(key);
      } else {
        values.put(key, value);
      }
    }
    if (missingKeys.size() > 0) {
      Joiner joiner = Joiner.on(", ");
      String message = "Must supply value for configuration settings: " + joiner.join(missingKeys);
      throw new IOException(message);
    }
    return values;
  }
1024773
@SuppressWarnings("unchecked") // when we cast yaml.load(fin)
  public static Map<String, Object> loadFile(String fileName) {
    Map<String, Object> props = new HashMap<>();
    if (fileName == null) {
      LOG.warning("Config file name cannot be null");
      return props;
    } else if (fileName.isEmpty()) {
      LOG.warning("Config file name is empty");
      return props;
    } else {

      // check if the file exists and also it is a regular file
      Path path = Paths.get(fileName);

      if (!Files.exists(path)) {
        LOG.fine("Config file " + fileName + " does not exist");
        return props;
      }

      if (!Files.isRegularFile(path)) {
        LOG.warning("Config file " + fileName + " might be a directory.");
        return props;
      }

      LOG.log(Level.FINE, "Reading config file {0}", fileName);

      Map<String, Object> propsYaml = null;
      try {
        FileInputStream fin = new FileInputStream(new File(fileName));
        try {
          Yaml yaml = new Yaml();
          propsYaml = (Map<String, Object>) yaml.load(fin);
          LOG.log(Level.FINE, "Successfully read config file {0}", fileName);
        } finally {
          fin.close();
        }
      } catch (IOException e) {
        LOG.log(Level.SEVERE, "Failed to load config file: " + fileName, e);
      }

      return propsYaml != null ? propsYaml : props;
    }
  }
220544
def write_config(self, outfile):
        """"""
        utils.write_yaml(self.config, outfile, default_flow_style=False)