From 1c7cf886dc5aa9fdeb0396deb00dedfbbf785155 Mon Sep 17 00:00:00 2001 From: JazzyNico Date: Tue, 23 Jun 2009 19:32:09 +0000 Subject: [PATCH] Partial fix for bug #386664. --- share/extensions/svg_and_media_zip_output.py | 29 ++++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/share/extensions/svg_and_media_zip_output.py b/share/extensions/svg_and_media_zip_output.py index 88c294245..6aaf3b226 100644 --- a/share/extensions/svg_and_media_zip_output.py +++ b/share/extensions/svg_and_media_zip_output.py @@ -56,24 +56,23 @@ class SVG_and_Media_ZIP_Output(inkex.Effect): def clear_tmp(self): shutil.rmtree(self.tmp_dir) - def effect(self): ttmp_orig = self.document.getroot() docname = ttmp_orig.get(inkex.addNS('docname',u'sodipodi')) if docname is None: docname = self.args[-1] - #orig_tmpfile = sys.argv[1] - #create os temp dir self.tmp_dir = tempfile.mkdtemp() - # create destination zip in same directory as the document - self.zip_file = self.tmp_dir + os.path.sep + docname + '.zip' - z = zipfile.ZipFile(self.zip_file, 'w') - #fixme replace whatever extention docstripped = docname.replace('.zip', '') + docstripped = docstripped.replace('.svg', '') + docstripped = docstripped.replace('.svgz', '') + + # create destination zip in same directory as the document + self.zip_file = os.path.join(self.tmp_dir, docstripped) + '.zip' + z = zipfile.ZipFile(self.zip_file, 'w') #read tmpdoc and copy all images to temp dir for node in self.document.xpath('//svg:image', namespaces=inkex.NSS): @@ -87,14 +86,14 @@ class SVG_and_Media_ZIP_Output(inkex.Effect): stream.close() - z.write(dst_file.encode("latin-1"),docstripped.encode("latin-1")+'.svg') - z.close() + z.write(dst_file,docstripped.encode("utf_8")+'.svg') + z.close() def collectAndZipImages(self, node, docname, z): xlink = node.get(inkex.addNS('href',u'xlink')) if (xlink[:4]!='data'): - absref=node.get(inkex.addNS('absref','sodipodi')) + absref=node.get(inkex.addNS('absref',u'sodipodi')) url=urlparse.urlparse(xlink) href=urllib.unquote(url.path) if os.name == 'nt' and href[0] == '/': @@ -104,12 +103,12 @@ class SVG_and_Media_ZIP_Output(inkex.Effect): if (os.path.isfile(absref)): shutil.copy(absref, self.tmp_dir) - z.write(absref.encode("latin-1"),os.path.basename(absref).encode("latin-1")) - elif (os.path.isfile(self.tmp_dir + os.path.sep + absref)): + z.write(absref, os.path.basename(absref).encode("utf_8")) + elif (os.path.isfile(os.path.join(self.tmp_dir, absref))): #TODO: please explain why this clause is necessary - shutil.copy(self.tmp_dir + os.path.sep + absref, self.tmp_dir) - z.write(self.tmp_dir + os.path.sep + absref.encode("latin-1"), - os.path.basename(absref).encode("latin-1")) + shutil.copy(os.path.join(self.tmp_dir, absref), self.tmp_dir) + z.write(os.path.join(self.tmp_dir, absref), + os.path.basename(absref).encode("utf_8")) else: inkex.errormsg(_('Could not locate file: %s') % absref) -- 2.30.2