summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cf8d3ad)
raw | patch | inline | side by side (parent: cf8d3ad)
author | JazzyNico <JazzyNico@users.sourceforge.net> | |
Tue, 23 Jun 2009 19:32:09 +0000 (19:32 +0000) | ||
committer | JazzyNico <JazzyNico@users.sourceforge.net> | |
Tue, 23 Jun 2009 19:32:09 +0000 (19:32 +0000) |
share/extensions/svg_and_media_zip_output.py | patch | blob | history |
diff --git a/share/extensions/svg_and_media_zip_output.py b/share/extensions/svg_and_media_zip_output.py
index 88c294245283617390c7bf12dd0b64114f8407b1..6aaf3b2262ec42fdae0e693f10af7852779fbe29 100644 (file)
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):
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] == '/':
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)