Write branch and tag to meta.yaml by editing in place
480841
def _write_branch_and_tag_to_meta_yaml(self):
        
        ## set the branch to pull source from
        with open(self.meta_yaml.replace("meta", "template"), 'r') as infile:
            dat = infile.read()
            newdat = dat.format(**{'tag': self.tag, 'branch': self.branch})

        with open(self.meta_yaml, 'w') as outfile:
            outfile.write(newdat)
1256636
def merge_replacement_files(tmpdir, mergefile):
  """"""
  # The fixes suggested by clang-tidy >= 4.0.0 are given under
  # the top level key 'Diagnostics' in the output yaml files
  mergekey="Diagnostics"
  merged=[]
  for replacefile in glob.iglob(os.path.join(tmpdir, '*.yaml')):
    content = yaml.safe_load(open(replacefile, 'r'))
    if not content:
      continue # Skip empty files.
    merged.extend(content.get(mergekey, []))

  if merged:
    # MainSourceFile: The key is required by the definition inside
    # include/clang/Tooling/ReplacementsYaml.h, but the value
    # is actually never used inside clang-apply-replacements,
    # so we set it to '' here.
    output = { 'MainSourceFile': '', mergekey: merged }
    with open(mergefile, 'w') as out:
      yaml.safe_dump(output, out)
  else:
    # Empty the file:
    open(mergefile, 'w').close()
85601
function performChange(content) {
  const exampleFile = ExampleFile.fromPath(this.file.path);
  const match = content.match(/<!---([\s\S]*)?--->/);
  if (!match) {
    return content;
  }
  gutil.log('changing', exampleFile.title);
  const frontmatter = JSON.parse(match[1]);
  const yaml = require('js-yaml');
  const yamlFrontmatter = `<!---

${yaml.safeDump(frontmatter)}
--->
${content.substring(match[0].length)}`;
  /*
  if (!/<title>/.test(content)) {
    content = content.replace(/<meta charset="utf-8">/g,
        '<meta charset="utf-8">\n  <title>' + exampleFile.title() + '</title>');
  }
  */
  return yamlFrontmatter;
}
756944
def generate_code(meta, prefix=None, node=False, min=False):
    
    if isinstance(meta, dict):
        url_prefix, auth_header, resources = parse_meta(meta)
    else:
        url_prefix, auth_header, resources = meta
    if prefix is not None:
        url_prefix = prefix
    core = render_core(url_prefix, auth_header, resources)
    if min:
        filename = 'res.web.min.js'
    else:
        filename = 'res.web.js'
    if node:
        filename = 'res.node.js'
    base = read_file(filename)
    return base.replace('"#res.core.js#"', core)
167283
def apply_yaml_file(data, filename):
    
    changed_data = copy.deepcopy(data)

    if filename == '-':
        new_options = yaml.safe_load(sys.stdin)
    else:
        with open(filename) as fd:
            new_options = yaml.safe_load(fd)

    patch_config(changed_data, new_options)

    return format_config_for_editing(changed_data), changed_data
645721
def write_yaml (self, data, encoding=None, errors=None, newline=None, **kwargs):
        
        import yaml

        with self.open (mode='wt', encoding=encoding, errors=errors, newline=newline) as f:
            return yaml.dump (data, stream=f, **kwargs)
363840
def autoupdate(config_file, store, tags_only, repos=()):
    """"""
    migrate_config(config_file, quiet=True)
    retv = 0
    output_repos = []
    changed = False

    input_config = load_config(config_file)

    for repo_config in input_config['repos']:
        if (
            repo_config['repo'] in {LOCAL, META} or
            # Skip updating any repo_configs that aren't for the specified repo
            repos and repo_config['repo'] not in repos
        ):
            output_repos.append(repo_config)
            continue
        output.write('Updating {}...'.format(repo_config['repo']))
        try:
            new_repo_config = _update_repo(repo_config, store, tags_only)
        except RepositoryCannotBeUpdatedError as error:
            output.write_line(error.args[0])
            output_repos.append(repo_config)
            retv = 1
            continue

        if new_repo_config['rev'] != repo_config['rev']:
            changed = True
            output.write_line(
                'updating {} -> {}.'.format(
                    repo_config['rev'], new_repo_config['rev'],
                ),
            )
            output_repos.append(new_repo_config)
        else:
            output.write_line('already up to date.')
            output_repos.append(repo_config)

    if changed:
        output_config = input_config.copy()
        output_config['repos'] = output_repos
        _write_new_config_file(config_file, output_config)

    return retv
316057
def write_yaml_to_file(file)
      file = if file.is_a?(String)
               File.new(file, 'w')
             else
               file
             end

      content = {
        source_file_path: source_file_path,
        code_string: code_string,
      }.to_yaml

      file.write(content)
      file.flush
    end
240454
def to_yaml(self, skip_nulls=True):
        """"""
        return yaml.safe_dump(self.to_dict(skip_nulls=skip_nulls),
                              default_flow_style=False)
295931
function create_meta_info (meta_title, meta_description, meta_sort) {

  var yamlDocument = {};
  var meta_info_is_present = meta_title || meta_description || meta_sort;

  if (meta_info_is_present) {
    if (meta_title)       { yamlDocument.Title       = meta_title;              }
    if (meta_description) { yamlDocument.Description = meta_description;        }
    if (meta_sort)        { yamlDocument.Sort        = parseInt(meta_sort, 10); }

    return '---\n' + yaml.safeDump(yamlDocument) + '---\n';
  } else {
    return '---\n---\n';
  }

}
1228024
def save(yaml_dict, filepath):
    '''
    
    '''
    yamldict.dump(yaml_dict, open(filepath, 'w'), default_flow_style=False)
1343595
function writeYAMLConfigFile(config, filePath) {
    debug(`Writing YAML config file: ${filePath}`);

    // lazy load YAML to improve performance when not used
    const yaml = require("js-yaml");

    const content = yaml.safeDump(config, { sortKeys: true });

    fs.writeFileSync(filePath, content, "utf8");
}
1188591
def _write_template(upgrade_file, name, depends_on, repository, auto=False):
    """"""
    if auto:
        # Ensure all models are loaded
        from invenio_db import models
        list(models)
        template_args = produce_upgrade_operations()
        operations_str = template_args['upgrades']
        import_str = template_args['imports']
    else:
        operations_str = "    pass"
        import_str = ""

    with open(upgrade_file, 'w') as f:
        f.write(UPGRADE_TEMPLATE % {
            'depends_on': depends_on,
            'repository': repository,
            'year': date.today().year,
            'operations': operations_str,
            'imports': import_str,
            'cls': ''.join(w.capitalize() or '_' for w in name.split('_'))
        })
998952
def write_metadata
      unless disabled?
        Jekyll.logger.debug "Writing Metadata:", ".jekyll-metadata"
        File.binwrite(metadata_file, Marshal.dump(metadata))
      end
    end
346480
def __git_tag(git_tag):
        
        command = ['git', 'tag', '-a', git_tag, '-m', '\'' + git_tag + '\'']
        Shell.msg('Create tag from version ' + git_tag)

        if APISettings.DEBUG:
            Git.__debug(command, False)

        if not call(command):
            return True
        return False
1186302
function(entry) {
    extend(entry, getTagDict(entry));

    // strip properties we don't want
    // entry.comment = undefined;
    entry.___id = undefined;
    entry.___s  = undefined;
    entry.tags  = undefined;

    // generate `.filepath` and `.lineno` from `.meta`
    if (entry.meta && entry.meta.path) {
      var currentDir = entry.meta.path.replace(process.env.PWD, "");

      entry.filename = entry.meta.filename;
      entry.filepath = process.env.PROJECT_REPO + currentDir + "/" + entry.filename;
      entry.lineno   = entry.meta.lineno;
    }

    entry.meta = undefined;

    names.push(entry.longname);

    dataContents[entry.longname] = entry;
  }
1010513
def write_example_yaml(cls, dest, skip=()):
        
        # Make sure we can make an instance before we open a file.
        inst = cls.example_instance(skip=skip)
        with open(dest, 'w') as f:
            inst.to_yaml(stream=f, skip=skip)