Пример #1
0
    def _write_tempfile(self, fileName=None, encoding="utf-8"):
        if fileName is None:
            fd, fileName = tempfile.mkstemp(".svg", "svgfig-")
            os.close(fd)
        else:
            fileName = defaults._expand_fileName(fileName)

        self.save(fileName, encoding)
        return fileName
Пример #2
0
    def _write_tempfile(self, fileName=None, encoding="utf-8"):
        if fileName is None:
            fd, fileName = tempfile.mkstemp(".svg", "svgfig-")
            os.close(fd)
        else:
            fileName = defaults._expand_fileName(fileName)

        self.save(fileName, encoding)
        return fileName
Пример #3
0
    def save(self, fileName, encoding="utf-8", compresslevel=None):
        fileName = defaults._expand_fileName(fileName)

        if compresslevel is not None or re.search(r"\.svgz$", fileName, re.I) or re.search(r"\.gz$", fileName, re.I):
            import gzip
            if compresslevel is None:
                f = gzip.GzipFile(fileName, "w")
            else:
                f = gzip.GzipFile(fileName, "w", compresslevel)

            f = codecs.EncodedFile(f, "utf-16", encoding)
            f.write(self.xml())
            f.close()

        else:
            f = codecs.open(fileName, "w", encoding=encoding)
            f.write(self.xml())
            f.close()

        saved.append(fileName)
Пример #4
0
    def save(self, fileName, encoding="utf-8", compresslevel=None):
        fileName = defaults._expand_fileName(fileName)

        if compresslevel is not None or re.search(r"\.svgz$", fileName, re.I) or re.search(r"\.gz$", fileName, re.I):
            import gzip
            if compresslevel is None:
                f = gzip.GzipFile(fileName, "w")
            else:
                f = gzip.GzipFile(fileName, "w", compresslevel)

            f = codecs.EncodedFile(f, "utf-16", encoding)
            f.write(self.xml())
            f.close()

        else:
            f = codecs.open(fileName, "w", encoding=encoding)
            f.write(self.xml())
            f.close()

        saved.append(fileName)