summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2009-06-23 19:32:09 +0000
committerJazzyNico <JazzyNico@users.sourceforge.net>2009-06-23 19:32:09 +0000
commit3cfb0c15134a504cec4bc95d5a6d516cb8582c0f (patch)
tree461e555f0986bebcb97d909e4159bfc958e37b14
parentUpdated Russian translation (diff)
downloadinkscape-3cfb0c15134a504cec4bc95d5a6d516cb8582c0f.tar.gz
inkscape-3cfb0c15134a504cec4bc95d5a6d516cb8582c0f.zip
Partial fix for bug #386664.
(bzr r8153)
-rw-r--r--share/extensions/svg_and_media_zip_output.py29
1 files 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)