Update the ostree summary file and return a path to it
425057
def update_ostree_summary(self, release):
        """"""
        self.log.info('Updating the ostree summary for %s', release['name'])
        self.mock_chroot(release, release['ostree_summary'])
        return os.path.join(release['output_dir'], 'summary')
1129797
def update_file path, matcher, currentVersion, nextVersion
      temp_path = "#{path}.autoversion"

      begin
        File.open(path) do |source|
          File.open(temp_path, 'w') do |target|
            source.each do |line|
              if matcher.call(line)
                target.write line.gsub currentVersion.to_s, nextVersion.to_s
              else
                target.write line
              end
            end
          end
        end

        File.rename temp_path, path
      ensure
        File.unlink temp_path if File.file? temp_path
      end
    end
1120546
function updateIosPlist (targetFilePath, configItems) {
        var infoPlist = plist.parse(fs.readFileSync(targetFilePath, 'utf-8')),
            tempInfoPlist;

        _.each(configItems, function (item) {
            var key = item.parent;
            var plistXml = '<plist><dict><key>' + key + '</key>';
            plistXml += eltreeToXmlString(item.data) + '</dict></plist>';

            var configPlistObj = plist.parse(plistXml);
            infoPlist[key] = configPlistObj[key];
            logger.verbose("Write to plist; key="+key+"; value="+tostr(configPlistObj[key]));
        });

        tempInfoPlist = plist.build(infoPlist);
        tempInfoPlist = tempInfoPlist.replace(/<string>[\s\r\n]*<\/string>/g,'<string></string>');
        fs.writeFileSync(targetFilePath, tempInfoPlist, 'utf-8');
    }
547673
def upgrade_file(path, multipoint):
    """"""
    node0 = nrml.read(path, chatty=False)[0]
    shutil.copy(path, path + '.bak')  # make a backup of the original file
    tag = striptag(node0.tag)
    gml = True
    if tag == 'vulnerabilityModel':
        vf_dict, cat_dict = get_vulnerability_functions_04(path)
        # below I am converting into a NRML 0.5 vulnerabilityModel
        node0 = Node(
            'vulnerabilityModel', cat_dict,
            nodes=[obj_to_node(val) for val in vf_dict.values()])
        gml = False
    elif tag == 'fragilityModel':
        node0 = read_nrml.convert_fragility_model_04(
            nrml.read(path)[0], path)
        gml = False
    elif tag == 'sourceModel':
        node0 = nrml.read(path)[0]
        dic = groupby(node0.nodes, operator.itemgetter('tectonicRegion'))
        node0.nodes = [Node('sourceGroup',
                            dict(tectonicRegion=trt, name="group %s" % i),
                            nodes=srcs)
                       for i, (trt, srcs) in enumerate(dic.items(), 1)]
        if multipoint:
            sourceconverter.update_source_model(node0, path + '.bak')
    with open(path, 'wb') as f:
        nrml.write([node0], f, gml=gml)
252482
def update_module_file(redbaron_tree, module_path, show_diff=False, dry_run=False):
    
    with tempfile.NamedTemporaryFile() as tmp_file:
        tmp_file.write(redbaron_tree_to_module_str(redbaron_tree))
        tmp_file.seek(0)
        if are_files_equal(module_path, tmp_file.name):
            logging.debug('Source unchanged')
            return False

        logging.debug('Source modified')

        tmp_file.seek(0)
        diff_update_file(module_path, tmp_file.read(), show_diff, dry_run)
149632
def run(self, path):
        ''''''

        SEPARATOR = '=' * 40
        summary = {}
        res = True

        for _f in utils.get_files_by_path(path):
            L.info(SEPARATOR)
            status, summ = self._check_file(_f)
            res &= status
            if summ is not None:
                summary.update(summ)

        L.info(SEPARATOR)

        status = 'PASS' if res else 'FAIL'

        return {'files': summary, 'STATUS': status}
454151
function _openPath(treeData, path) {
        var objectPath = _filePathToObjectPath(treeData, path);

        function setOpen(node) {
            return node.set("open", true);
        }

        while (objectPath && objectPath.length) {
            var node = treeData.getIn(objectPath);
            if (isFile(node)) {
                objectPath.pop();
            } else {
                if (!node.get("open")) {
                    treeData = treeData.updateIn(objectPath, setOpen);
                }
                objectPath.pop();
                if (objectPath.length) {
                    objectPath.pop();
                }
            }
        }

        return treeData;
    }
847791
def _update_raster_info(self, **update_props):
        

        xpath_map = self._data_structures[update_props['prop']]

        return [
            update_complex(xpath_root=self._data_map.get('_raster_info_root'), xpath_map=xpath_map, **update_props),
            update_complex(xpath_root=self._data_map.get('__raster_res_root'), xpath_map=xpath_map, **update_props)
        ]
252879
def add_file_path_in_work_tree(self, path, work_tree, verbose=True):
        
        args = ['--work-tree', work_tree, 'add', '-f']
        if verbose:
            args.append('--verbose')
        args.append(path)
        self.command_exec(args, show_output=verbose)
429004
function updatePathInternal(sourcePath, targetPath, options, log) {
    var rootDir = (options && options.rootDir) || "";
    var targetFullPath = path.join(rootDir, targetPath);
    var targetStats = fs.existsSync(targetFullPath) ? fs.statSync(targetFullPath) : null;
    var sourceStats = null;

    if (sourcePath) {
        // A non-null source path was specified. It should exist.
        var sourceFullPath = path.join(rootDir, sourcePath);
        if (!fs.existsSync(sourceFullPath)) {
            throw new Error("Source path does not exist: " + sourcePath);
        }

        sourceStats = fs.statSync(sourceFullPath);

        // Create the target's parent directory if it doesn't exist.
        var parentDir = path.dirname(targetFullPath);
        if (!fs.existsSync(parentDir)) {
            shell.mkdir("-p", parentDir);
        }
    }

    return updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, options, log);
}
884518
def diff(self, old, new, rel_path=None):
        
        full_url_or_path = self.__url_or_path
        if rel_path is not None:
            full_url_or_path += '/' + rel_path
        diff_result = self.run_command(
            'diff',
            ['--old', '{0}@{1}'.format(full_url_or_path, old),
             '--new', '{0}@{1}'.format(full_url_or_path, new)],
            do_combine=True)
        file_to_diff = {}
        for non_empty_diff in filter(None, diff_result.decode('utf8').split('Index: ')):
            split_diff = non_empty_diff.split('==')
            file_to_diff[split_diff[0].strip().strip('/')] = split_diff[-1].strip('=').strip()
        diff_summaries = self.diff_summary(old, new, rel_path)
        for diff_summary in diff_summaries:
            diff_summary['diff'] = \
                file_to_diff[diff_summary['path'].split(full_url_or_path)[-1].strip('/')]
        return diff_summaries
516757
def update_mode(arg_namespace):
    """"""
    try:
        updater.update(custom_sources=arg_namespace.custom)
    except (PermissionError, FileNotFoundError) as exception:
        if isinstance(exception, PermissionError):
            print('No write permission for current working directory.')
        if isinstance(exception, FileNotFoundError):
            print('Necessary resources for updating not found in current '
                  'working directory.')
496198
def update_if_outdated(folder):
    

    folders = []
    while os.path.isdir(folder):
        folders.append(folder)
        # Get info.yml
        with open(os.path.join(folder, "info.yml")) as ymlfile:
            content = yaml.load(ymlfile)
        folder = os.path.join(utils.get_project_root(), content['data-source'])
    raw_source_file = folder
    if not os.path.isfile(raw_source_file):
        logging.error("File '%s' was not found.", raw_source_file)
        logging.error("You should eventually execute 'hwrt download'.")
        sys.exit(-1)
    dt = os.path.getmtime(raw_source_file)
    source_mtime = datetime.datetime.utcfromtimestamp(dt)
    folders = folders[::-1]  # Reverse order to get the most "basic one first"

    for target_folder in folders:
        target_mtime = utils.get_latest_successful_run(target_folder)
        if target_mtime is None or source_mtime > target_mtime:
            # The source is later than the target. That means we need to
            # refresh the target
            if "preprocessed" in target_folder:
                logging.info("Preprocessed file was outdated. Update...")
                preprocess_dataset.main(os.path.join(utils.get_project_root(),
                                                     target_folder))
            elif "feature-files" in target_folder:
                logging.info("Feature file was outdated. Update...")
                create_ffiles.main(target_folder)
            elif "model" in target_folder:
                logging.info("Model file was outdated. Update...")
                create_model.main(target_folder, True)
            target_mtime = datetime.datetime.utcnow()
        else:
            logging.info("'%s' is up-to-date.", target_folder)
        source_mtime = target_mtime
756960
def update_file(filename, items):
    '''
    '''
    # TODO: Implement something in the templates to denote whether the value
    # being replaced is an XML attribute or a value. Perhaps move to dyanmic
    # XML tree building rather than string replacement.
    should_escape = filename.endswith('addon.xml')

    with open(filename, 'r') as inp:
        text = inp.read()

    for key, val in items.items():
        if should_escape:
            val = saxutils.quoteattr(val)
        text = text.replace('{%s}' % key, val)
    output = text

    with open(filename, 'w') as out:
        out.write(output)
110750
def update_file(self, path):
        '''
        
        '''
        try:
            # grab the file
            result, stat = self.zoo_client.get(path, watch=self.watch_file)
        except ZookeeperError:
            self.set_valid(False)
            self.call_error(self.INVALID_GET)
            return False

        if self.pointer:
            if result is not None and len(result) > 0:
                self.pointed_at_expired = False
                # file is a pointer, go update and watch other file
                self.point_path = result
                if self.compare_pointer(result):
                    self.update_pointed()
            else:
                self.pointed_at_expired = True
                self.old_pointed = ''
                self.old_data = ''
                self.set_valid(False)
                self.call_error(self.INVALID_PATH)
        else:
            # file is not a pointer, return contents
            if self.compare_data(result):
                self.call_config(result)
            self.set_valid(True)

        return True
516849
def set_tree(self, tree):
        
        self.tree = tree
        self.__record_progress(Status.DOWNLOAD_FILES)
248123
def update_mandb_path():
    """"""
    manpath_file = os.path.join(environ.HOME, ".manpath")
    man_dir      = environ.cache_dir
    manindex_dir = environ.manindex_dirl

    lines = []

    """ read all lines """
    try:
        with open(manpath_file, 'r') as f:
            lines = f.readlines()
    except IOError:
        return

    """ remove MANDATORY_MANPATH and MANDB_MAP entry """
    lines = [line for line in lines if man_dir not in line]

    with open(manpath_file, 'w') as f:
        if environ.config.UpdateManPath:
            lines.append('MANDATORY_MANPATH\t%s\n' % man_dir)
            lines.append('MANDB_MAP\t\t\t%s\t%s\n' % (man_dir, manindex_dir))

        f.writelines(lines)