summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8ad3a92)
raw | patch | inline | side by side (parent: 8ad3a92)
author | JazzyNico <nicoduf@yahoo.fr> | |
Wed, 3 Mar 2010 13:04:57 +0000 (14:04 +0100) | ||
committer | JazzyNico <nicoduf@yahoo.fr> | |
Wed, 3 Mar 2010 13:04:57 +0000 (14:04 +0100) |
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 341de728b94b4738d67aa6c0282ab8045abe59c0..8308d60623b149000a3856a580e2b730338e8bcb 100644 (file)
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-Version 0.4 (Nicolas Dufour, nicoduf@yahoo.fr)
- fix a coding bug: now use UTF-8 to save filenames in the archive.
- fix xlink href parsing (now a real URL in 0.47).
- fix Win32 stdout \r\r\n bug (stdout now set to bin mode).
- fix a double .svg extension bug (added svg and svgz in the docstripped extensions).
+Version 0.5 (Nicolas Dufour, nicoduf@yahoo.fr)
+ Fix a bug related to special caracters in the path (LP #456248).
TODO
- fix bug: not saving existing .zip after a Collect for Output is run
the file name is still xxx.zip. after saving again the file xxx.zip is written with a plain .svg which
looks like a corrupt zip
- maybe add better extention
+- consider switching to lzma in order to allow cross platform compression with no encoding problem...
"""
import inkex
class SVG_and_Media_ZIP_Output(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
+ if os.name == 'nt':
+ self.encoding = "cp437"
+ else:
+ self.encoding = "latin-1"
def output(self):
out = open(self.zip_file,'rb')
stream.close()
- z.write(dst_file,docstripped.encode("utf_8")+'.svg')
+ z.write(dst_file,docstripped.encode(self.encoding)+'.svg')
z.close()
if (xlink[:4]!='data'):
absref=node.get(inkex.addNS('absref',u'sodipodi'))
url=urlparse.urlparse(xlink)
- href=urllib.unquote(url.path)
- if os.name == 'nt' and href[0] == '/':
- href = href[1:]
+ href=urllib.url2pathname(url.path)
+
if (href != None):
absref=os.path.realpath(href)
+ absref=unicode(absref, "utf-8")
+
if (os.path.isfile(absref)):
shutil.copy(absref, self.tmp_dir)
- z.write(absref, os.path.basename(absref).encode("utf_8"))
+ z.write(absref, os.path.basename(absref).encode(self.encoding))
elif (os.path.isfile(os.path.join(self.tmp_dir, absref))):
#TODO: please explain why this clause is necessary
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"))
+ os.path.basename(absref).encode(self.encoding))
else:
inkex.errormsg(_('Could not locate file: %s') % absref)