Updates a local copy of PSL file

    :param psl_file: path for the file to store the list. Default: PSLFILE
979916
def updatePSL(psl_file=PSLFILE):
    
    if requests is None:
        raise Exception("Please install python-requests http(s) library. $ sudo pip install requests")


    r = requests.get(PSLURL)
    if r.status_code != requests.codes.ok or len(r.content) == 0:
        raise Exception("Could not download PSL from " + PSLURL)

    lastmod = r.headers.get("last-modified", None)
    f = open(psl_file + ".swp", "wb")
    f.write(r.content)
    f.close()

    with open(psl_file + ".swp", "rb") as f:
        psl = PublicSuffixList(f)

    os.rename(psl_file + ".swp", psl_file)
    if lastmod:
        t = time.mktime(parsedate(lastmod))
        os.utime(psl_file, (t, t))

    print("PSL updated")
    if lastmod:
        print("last-modified: " + lastmod)
751397
def save_pkl(self, filename):
        
        with open(filename, 'wb') as fout:
            pickle.dump(self, fout)
185642
def update_version_file(version)
      if File.exists?('VERSION')
        File.open('VERSION', 'w') { |f| f << version.to_s }
        modified_files << 'VERSION'
      end
    end
492958
def update_file(self):
        
        if self._filename is None:
            raise NoConfigFileReadError()
        with open(self._filename, 'w') as fb:
            self.write(fb)
217039
def _update_card_file_location(self, card_name, new_directory):
        
        with tmp_chdir(self.gssha_directory):
            file_card = self.project_manager.getCard(card_name)
            if file_card:
                if file_card.value:
                    original_location = file_card.value.strip("'").strip('"')
                    new_location = os.path.join(new_directory,
                                                os.path.basename(original_location))
                    file_card.value = '"{0}"'.format(os.path.basename(original_location))
                    try:
                        move(original_location, new_location)
                    except OSError as ex:
                        log.warning(ex)
                        pass
767763
def update_translations(self, project_id, file_path=None,
                            language_code=None, overwrite=False, fuzzy_trigger=None):
        
        return self._upload(
            project_id=project_id,
            updating=self.UPDATING_TRANSLATIONS,
            file_path=file_path,
            language_code=language_code,
            overwrite=overwrite,
            fuzzy_trigger=fuzzy_trigger
        )
916910
def UpdateResourcesFromDataFile(dstpath, srcpath, type_, names=None, 
                                languages=None):
    
    src = open(srcpath, "rb")
    data = src.read()
    src.close()
    UpdateResources(dstpath, data, type_, names, languages)
184268
public static void update(final FileUpdater updater, final File destFile) throws UpdateException {
        final File lockFile = new File(destFile.getAbsolutePath() + ".lock");
        final File newDestFile = new File(destFile.getAbsolutePath() + ".new");

        try {
            // synchronize writing to file within this jvm
            synchronized (UpdateUtils.class) {
                final FileChannel channel = new RandomAccessFile(lockFile, "rw").getChannel();

                //acquire file lock to block external jvm (commandline) from writing to file
                final FileLock lock = channel.lock();
                try {
                    FileUtils.copyFileStreams(destFile, newDestFile);
                    updater.updateFile(newDestFile);
                    if (newDestFile.isFile() && newDestFile.length() > 0) {
                        moveFile(newDestFile, destFile);
                    } else {
                        throw new UpdateException("Result file was empty or not present: " + newDestFile);
                    }
                } catch (FileUpdaterException e) {
                    throw new UpdateException(e);
                } finally {
                    lock.release();
                    channel.close();
                }
            }
        } catch (IOException e) {
            throw new UpdateException("Unable to get and write file: " +
                    e.toString(), e);
        }
    }
910034
def file_local_list(self, saltenv='base'):
        '''
        
        '''
        filesdest = os.path.join(self.opts['cachedir'], 'files', saltenv)
        localfilesdest = os.path.join(self.opts['cachedir'], 'localfiles')

        fdest = self._file_local_list(filesdest)
        ldest = self._file_local_list(localfilesdest)
        return sorted(fdest.union(ldest))
688527
def copy_file(self, from_path, to_path, replace=False):
        
        f = self.get_file(from_path)
        if f.copy(to_path, replace):
            self.set_cache_buster(to_path, f.hash())
271332
def put(self, filename):
        
        from . import LocalFile
        target = get_target_path(filename, self.source)
        with self.open('rb') as infile, open(target, 'wb') as outfile:
            shutil.copyfileobj(infile, outfile)
        return LocalFile(target)
244370
private void updateList(final File filename) {
        try {
            final URI reletivePath = toURI(filename.getAbsolutePath().substring(new File(normalize(tempDir.toString())).getPath().length() + 1));
            final FileInfo f = job.getOrCreateFileInfo(reletivePath);
            if (hasConref) {
                f.hasConref = true;
            }
            if (hasKeyref) {
                f.hasKeyref = true;
            }
            job.write();
        } catch (final RuntimeException e) {
            throw e;
        } catch (final Exception e) {
            logger.error(e.getMessage(), e) ;
        }
    }
1345379
def __store_recent_file(self, file):
        

        LOGGER.debug("> Storing '{0}' file in recent files.".format(file))

        recentFiles = [foundations.strings.to_string(recentFile)
                       for recentFile in self.__settings.get_key(self.__settings_section, "recentFiles").toStringList()
                       if foundations.common.path_exists(recentFile)]
        if not recentFiles:
            recentFiles = []

        if file in recentFiles:
            recentFiles.pop(recentFiles.index(file))
        recentFiles.insert(0, file)
        del recentFiles[self.__maximum_recent_files:]
        recentFiles = self.__settings.set_key(self.__settings_section, "recentFiles", recentFiles)
        self.recent_files_changed.emit()
447744
def update(self, source_file, configuration, declarations, included_files):
        

        record = record_t(
            source_signature=file_signature(source_file),
            config_signature=configuration_signature(configuration),
            included_files=included_files,
            included_files_signature=list(
                map(
                    file_signature,
                    included_files)),
            declarations=declarations)
        # Switched over to holding full record in cache so we don't have
        # to keep creating records in the next method.
        self.__cache[record.key()] = record
        self.__cache[record.key()].was_hit = True
        self.__needs_flushed = True
97317
def soft_target_update(self):
    
    for target_param, local_param in zip(self.target.parameters(), self.local.parameters()):
      target_param.data.copy_(self.tau * local_param.data + (1.0 - self.tau) * target_param.data)
202228
def _update(self, rules: list):
        
        self._rules = rules
        to_store = '\n'.join(
            rule.config_string
            for rule in rules
        )
        sftp_connection = self._sftp_connection
        with sftp_connection.open(self.RULE_PATH, mode='w') as file_handle:
            file_handle.write(to_store)
287659
def save_file(self, srcfile):
        
        filehash = digest_file(srcfile)
        if not os.path.exists(self.object_path(filehash)):
            # Copy the file to a temporary location first, then move, to make sure we don't end up with
            # truncated contents if the build gets interrupted.
            tmppath = self.temporary_object_path(filehash)
            copyfile(srcfile, tmppath)
            self._move_to_store(tmppath, filehash)

        return filehash