Save relaxation keywords to .txt and .pyc file
334404
def report_and_save_keywords(self,relaxation_kwds,precomputed_kwds):
        """"""
        report_name = os.path.join(self.backup_dir,'relaxation_keywords.txt')
        pretty_relax_kwds = pprint.pformat(relaxation_kwds,indent=4)
        with open(report_name,'w') as wf:
            wf.write(pretty_relax_kwds)
        wf.close()

        origin_name = os.path.join(self.backup_dir,'relaxation_keywords.pyc')
        with open(origin_name,'wb') as ro:
            pickle.dump(relaxation_kwds,ro,protocol=pickle.HIGHEST_PROTOCOL)
        ro.close()

        if relaxation_kwds['presave']:
            precomp_kwds_name = os.path.join(self.backup_dir,
                                             'precomputed_keywords.pyc')
            with open(precomp_kwds_name, 'wb') as po:
                pickle.dump(precomputed_kwds, po,
                            protocol=pickle.HIGHEST_PROTOCOL)
            po.close()
397646
def open_keyword_cache_path(self):
        """"""
        # noinspection PyCallByClass,PyTypeChecker
        file_name, __ = QFileDialog.getSaveFileName(
            self,
            self.tr('Set keyword cache file'),
            self.leKeywordCachePath.text(),
            self.tr('Sqlite DB File (*.db)'))
        if file_name:
            self.leKeywordCachePath.setText(file_name)
773607
def extract(filepath, taxonomy, output_mode, output_limit,
            spires, match_mode, detect_author_keywords, extract_acronyms,
            rebuild_cache, only_core_tags, no_cache):
    """"""
    if not filepath or not taxonomy:
        print("No PDF file or taxonomy given!", file=sys.stderr)
        sys.exit(0)

    click.echo(
        ">>> Going extract keywords from {0} as '{1}'...".format(
            filepath, output_mode
        )
    )
    if not os.path.isfile(filepath):
        click.echo(
            "Path to non-existing file\n",
        )
        sys.exit(1)

    result = get_keywords_from_local_file(
        local_file=filepath,
        taxonomy_name=taxonomy,
        output_mode=output_mode,
        output_limit=output_limit,
        spires=spires,
        match_mode=match_mode,
        no_cache=no_cache,
        with_author_keywords=detect_author_keywords,
        rebuild_cache=rebuild_cache,
        only_core_tags=only_core_tags,
        extract_acronyms=extract_acronyms
    )
    click.echo(result)
318166
def save_file(self, filename, text):
        """"""
        if not filename.endswith('.py'):
            filename += '.py'
        path = os.path.join(self.currentpath, filename)
        with open(path, 'w', encoding="utf-8") as file_:
            file_.write(text)
965325
def save_to_file(self,
                     file_path,
                     labels=None,
                     predict_proba=True,
                     show_predicted_value=True,
                     **kwargs):
        
        file_ = open(file_path, 'w', encoding='utf8')
        file_.write(self.as_html(labels=labels,
                                 predict_proba=predict_proba,
                                 show_predicted_value=show_predicted_value,
                                 **kwargs))
        file_.close()
1009650
def savetostr(self, sortkey = True):
        
        return ''.join(k + '=' + repr(v) + '\n' for k,v in self.config_items(sortkey))
427159
def _unify_keywords():
    '''
    
    '''
    old_path = BASE_PATH.format('keywords')
    if os.path.exists(old_path):
        if os.path.isdir(old_path):
            for triplet in salt.utils.path.os_walk(old_path):
                for file_name in triplet[2]:
                    file_path = '{0}/{1}'.format(triplet[0], file_name)
                    with salt.utils.files.fopen(file_path) as fh_:
                        for line in fh_:
                            line = salt.utils.stringutils.to_unicode(line).strip()
                            if line and not line.startswith('#'):
                                append_to_package_conf(
                                    'accept_keywords', string=line)
            shutil.rmtree(old_path)
        else:
            with salt.utils.files.fopen(old_path) as fh_:
                for line in fh_:
                    line = salt.utils.stringutils.to_unicode(line).strip()
                    if line and not line.startswith('#'):
                        append_to_package_conf('accept_keywords', string=line)
            os.remove(old_path)
651406
def save(self, filename="temp.pkl"):
    
    output = open(filename, 'wb')
    cPickle.dump(self.tm, output, protocol=cPickle.HIGHEST_PROTOCOL)
997914
def tokenize(self, path):
        """"""
        assert os.path.exists(path)
        # Add words to the dictionary
        with open(path, 'r') as f:
            tokens = 0
            for line in f:
                words = line.split() + ['<eos>']
                tokens += len(words)
                for word in words:
                    self.dictionary.add_word(word)

        # Tokenize file content
        with open(path, 'r') as f:
            ids = torch.LongTensor(tokens)
            token = 0
            for line in f:
                words = line.split() + ['<eos>']
                for word in words:
                    ids[token] = self.dictionary.word2idx[word]
                    token += 1

        return ids
1351959
def save_caption(self, filename: str, mtime: datetime, caption: str) -> None:
        """"""
        def _elliptify(caption):
            pcaption = caption.replace('\n', ' ').strip()
            return '[' + ((pcaption[:29] + u"\u2026") if len(pcaption) > 31 else pcaption) + ']'
        filename += '.txt'
        caption += '\n'
        pcaption = _elliptify(caption)
        caption = caption.encode("UTF-8")
        with suppress(FileNotFoundError):
            with open(filename, 'rb') as file:
                file_caption = file.read()
            if file_caption.replace(b'\r\n', b'\n') == caption.replace(b'\r\n', b'\n'):
                try:
                    self.context.log(pcaption + ' unchanged', end=' ', flush=True)
                except UnicodeEncodeError:
                    self.context.log('txt unchanged', end=' ', flush=True)
                return None
            else:
                def get_filename(index):
                    return filename if index == 0 else '{0}_old_{2:02}{1}'.format(*os.path.splitext(filename), index)

                i = 0
                while os.path.isfile(get_filename(i)):
                    i = i + 1
                for index in range(i, 0, -1):
                    os.rename(get_filename(index - 1), get_filename(index))
                try:
                    self.context.log(_elliptify(file_caption.decode("UTF-8")) + ' updated', end=' ', flush=True)
                except UnicodeEncodeError:
                    self.context.log('txt updated', end=' ', flush=True)
        try:
            self.context.log(pcaption, end=' ', flush=True)
        except UnicodeEncodeError:
            self.context.log('txt', end=' ', flush=True)
        with open(filename, 'wb') as text_file:
            shutil.copyfileobj(BytesIO(caption), text_file)
        os.utime(filename, (datetime.now().timestamp(), mtime.timestamp()))
71660
def save_to_file(self, filename_prefix):
    """"""
    # Wrap in single quotes to make it easier to see the full subword when
    # it has spaces and make it easier to search with ctrl+f.
    filename = self._filename(filename_prefix)
    lines = ["'%s'" % s for s in self._subwords]
    self._write_lines_to_file(filename, lines)
448125
def saveLogs(self, filename) :
		""""""
		f = open(filename, 'wb')
		cPickle.dump(self.logs, f)
		f.close()
712683
def _save_files(self, data, dtype_out_time):
        """"""
        path = self.path_out[dtype_out_time]
        if not os.path.isdir(self.dir_out):
            os.makedirs(self.dir_out)
        if 'reg' in dtype_out_time:
            try:
                reg_data = xr.open_dataset(path)
            except (EOFError, RuntimeError, IOError):
                reg_data = xr.Dataset()
            reg_data.update(data)
            data_out = reg_data
        else:
            data_out = data
        if isinstance(data_out, xr.DataArray):
            data_out = xr.Dataset({self.name: data_out})
        data_out.to_netcdf(path, engine='netcdf4', format='NETCDF3_64BIT')
377252
def save_analysis(self, filepath=None, **kwargs):
        
        # We pass a copy of the analysis attribute dictionary.
        dict_obj = deepcopy(self.analysis_output)
        # If no filepath is provided we create one.
        if filepath is None:
            filepath = "_".join(
                (str(self.system_id), "pywindow_analysis")
            )
            filepath = '/'.join((os.getcwd(), filepath))
        # Dump the dictionary to json file.
        Output().dump2json(dict_obj, filepath, default=to_list, **kwargs)
        return
1121808
def save_features(paths: List[str], datas: List[np.ndarray],
                  compressed: bool = False) -> List:
    
    fnames = []  # type: List[str]
    for path, data in zip(paths, datas):
        fnames.append(save_feature(path, data, compressed))
    return fnames
981441
def save_file(self):
        """"""

        l = []
        walk = self.walker
        for edit in walk.lines:
            # collect the text already stored in edit widgets
            if edit.original_text.expandtabs() == edit.edit_text:
                l.append(edit.original_text)
            else:
                l.append(re_tab(edit.edit_text))

        # then the rest
        while walk.file is not None:
            l.append(walk.read_next_line())

        # write back to disk
        outfile = open(self.save_name, "w")

        l_iter = iter(l)

        line = next(l_iter)
        prefix = ""

        while True:
            try:
                outfile.write(prefix + line)
                prefix = "\n"
                line = next(l_iter)
            except StopIteration:
                if line != "\n":
                    outfile.write("\n")
                break
505918
def _save_npz(self):
        '''
        

        '''

        # Save the data
        d = dict(self.__dict__)
        d.pop('_weights', None)
        d.pop('_A', None)
        d.pop('_B', None)
        d.pop('_f', None)
        d.pop('_mK', None)
        d.pop('K', None)
        d.pop('dvs', None)
        d.pop('clobber', None)
        d.pop('clobber_tpf', None)
        d.pop('_mission', None)
        d.pop('debug', None)
        np.savez(os.path.join(self.dir, self.name + '.npz'), **d)