def convert(self, filename, fmt): if fmt in ['svg', 'svg_Ponoko']: svg = svgutil.SVGFile(filename) svg.fix() else: ps = PSFile(filename) ps.adjustDocumentMedia() if fmt not in self._BASE_FORMATS: fd, tmpfile = tempfile.mkstemp(dir=os.path.dirname(filename)) cmd = [self.pstoedit] + self.formats[fmt] + [filename, tmpfile] err = subprocess.call(cmd) if err: # XXX show stderr output raise ValueError("Conversion failed. pstoedit returned %i" % err) os.rename(tmpfile, filename)
def convert(self, filename, fmt): if fmt == 'svg': svg = svgutil.SVGFile(filename) svg.getEnvelope() svg.rewriteViewPort() else: ps = PSFile(filename) ps.adjustDocumentMedia() if fmt not in ("svg", "ps"): fd, tmpfile = tempfile.mkstemp(dir=os.path.dirname(filename)) cmd = [self.pstoedit] + self.formats[fmt] + [filename, tmpfile] err = subprocess.call(cmd) if err: # XXX show stderr output raise ValueError("Conversion failed. pstoedit returned %i" % err) os.rename(tmpfile, filename)