Get subtitle file as a string.

        See :meth:`SSAFile.save()` for full description.

        Returns:
            str
494168
def to_string(self, format_, fps=None, **kwargs):
        
        fp = io.StringIO()
        self.to_file(fp, format_, fps=fps, **kwargs)
        return fp.getvalue()
1147646
def windowTitle( self ):
        
        output = os.path.basename(self._filename)
        if ( not output ):
            output = 'New Document'
        
        if ( self.isModified() ):
            output += '*'
        
        return output
1008508
def get_entry_text(self, fname):
        """"""
        if fname.split('.')[-1] == 'gz':
            with gz.open(fname, 'rt') as f:
                filetext = f.read()
        else:
            with codecs.open(fname, 'r') as f:
                filetext = f.read()
        return filetext
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()))
446939
function checkSubtitleFiles(options, fileWithHashes) {
    if (options.verbose) {
        _utils.logger.info('Checking existing subtitles...');
    }
    var promises = [];
    var _iteratorNormalCompletion3 = true;
    var _didIteratorError3 = false;
    var _iteratorError3 = undefined;

    try {
        for (var _iterator3 = fileWithHashes[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
            var file = _step3.value;

            promises.push(_utils.fileManager.subtitleExists(options, file));
        }
    } catch (err) {
        _didIteratorError3 = true;
        _iteratorError3 = err;
    } finally {
        try {
            if (!_iteratorNormalCompletion3 && _iterator3.return) {
                _iterator3.return();
            }
        } finally {
            if (_didIteratorError3) {
                throw _iteratorError3;
            }
        }
    }

    return Promise.all(promises);
}
255504
def _to_str(s):
    
    if sys.version_info[0] == 2 and not isinstance(s, str):
        # Assume it's Unicode, as that's what the PEP says
        # should be provided.
        return s.encode(sys.getfilesystemencoding())
    return s
792634
def libvlc_video_set_subtitle_file(p_mi, psz_subtitle):
    '''
    '''
    f = _Cfunctions.get('libvlc_video_set_subtitle_file', None) or \
        _Cfunction('libvlc_video_set_subtitle_file', ((1,), (1,),), None,
                    ctypes.c_int, MediaPlayer, ctypes.c_char_p)
    return f(p_mi, psz_subtitle)
400302
def save_as_header(self, response, **kwargs):
        
        save_as = kwargs.get('save_as', None)
        if save_as is False:
            return
        file_obj = kwargs.get('file_obj', None)
        if save_as is True or save_as is None:
            filename = os.path.basename(file_obj.path)
        else:
            filename = save_as
        response['Content-Disposition'] = smart_str(
            'attachment; filename=%s' % filename)
389091
def save(self, vs, filetype):
        ''

        # use NTF to generate filename and delete file on context exit
        with tempfile.NamedTemporaryFile(suffix='.'+filetype) as temp:
            saveSheets(temp.name, vs)
            sync(1)
            p = subprocess.Popen(
                self.command,
                stdin=open(temp.name, 'r', encoding=options.encoding),
                stdout=subprocess.DEVNULL,
                close_fds=True)
            p.communicate()
188444
def do_title(s):
    
    return ''.join(
        [item[0].upper() + item[1:].lower()
         for item in _word_beginning_split_re.split(soft_unicode(s))
         if item])
1306360
def get(self, filename):
        
        params = {
            "v": 'dreambox',
            "kolejka": "false",

            "nick": "",
            "pass": "",

            "napios": sys.platform,
            "l": self.language.upper(),

            "f": self.prepareHash(filename),
        }
        params['t'] = self.discombobulate(params['f'])

        url = self.url_base + urllib.urlencode(params)

        subs = urllib.urlopen(url).read()

        if subs.startswith('brak pliku tymczasowego'):
            raise NapiprojektException('napiprojekt.pl API error')

        if subs[0:4] != 'NPc0':
            # napiprojekt keeps subtitles in cp1250
            # ... but, sometimes they are in utf8
            for cdc in ['cp1250', 'utf8']:
                try:
                    return codecs.decode(subs, cdc)
                except:
                    pass
338905
def encode_tf(self, s):
    
    ids = subword_text_encoder_ops.subword_text_encoder_encode(
        s, self._filepath)
    # the c++ op apppends 1=EOS - drop it.
    return ids[:-1]
95436
def get_file(self):
        
        content = self._load()
        if not content:
            return None
        filename = "temporary_file.bin"
        with open(filename, "wb") as file_name:
            file_name.write(content)
        return filename
1049360
def get_tab_text(self, index, is_modified=None, is_readonly=None):
        """"""
        files_path_list = [finfo.filename for finfo in self.data]
        fname = self.data[index].filename
        fname = sourcecode.disambiguate_fname(files_path_list, fname)
        return self.__modified_readonly_title(fname,
                                              is_modified, is_readonly)
981751
def save(self):
        """"""
        with open(self.file_name, 'w') as fp:
            self.parser.write(fp)
        return self
955533
async function downloadSubtitles (file) {
  const subtitles = await getSubtitles(file)

  const { dir, name } = path.parse(file)

  const subtitlesFile = path.format({ dir, name, ext: '.srt' })

  await fs.writeFile(subtitlesFile, subtitles)

  return subtitlesFile
}
827699
def save(self, name, content):
        
        # Get the proper name for the file, as it will actually be saved.
        if name is None:
            name = content.name

        name = self.get_available_name(name)
        name = self._save(name, content)

        # Store filenames with forward slashes, even on Windows
        return name.replace("\\", "/")