Code

Embedimage extension fix and stderr Unicode support in inkex.py
authorJazzyNico <nicoduf@yahoo.fr>
Wed, 16 Dec 2009 20:31:01 +0000 (21:31 +0100)
committerJazzyNico <nicoduf@yahoo.fr>
Wed, 16 Dec 2009 20:31:01 +0000 (21:31 +0100)
share/extensions/embedimage.py
share/extensions/inkex.py

index 16439223b9cc79ebbd2127a3088ca4900833c119..f73ceb358dfac505d7bf2462156afba243e616ed 100644 (file)
@@ -56,9 +56,8 @@ class Embedder(inkex.Effect):
         if xlink is None or xlink[:5] != 'data:':
             absref=node.get(inkex.addNS('absref','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)
+            
             path=''
             #path selection strategy:
             # 1. href if absolute
@@ -70,6 +69,8 @@ class Embedder(inkex.Effect):
                 if (absref != None):
                     path=absref
 
+            path=unicode(path, "utf-8")
+
             if (not os.path.isfile(path)):
                 inkex.errormsg(_('No xlink:href or sodipodi:absref attributes found, or they do not point to an existing file! Unable to embed image.'))
                 if path:
index d36820692f19de89526d859a615d156d01840b8a..1a70c25d6e9e94bacb0c19e4f991108a677a4b94 100755 (executable)
@@ -84,7 +84,7 @@ def errormsg(msg):
          ...
          inkex.errormsg(_("This extension requires two selected paths."))
     """
-    sys.stderr.write((str(msg) + "\n").encode("UTF-8"))
+    sys.stderr.write((unicode(msg) + "\n").encode("UTF-8"))
 
 def check_inkbool(option, opt, value):
     if str(value).capitalize() == 'True':