index c85456c88bda1ad7640dffe032c68593cab4cb81..d5cf285c81041347aec9ab638440c1c81c651342 100644 (file)
'''
import inkex, base64, os
+import gettext
+_ = gettext.gettext
class MyEffect(inkex.Effect):
def __init__(self):
semicolon = xlink.find(';')
if semicolon>0:
for sub in mimesubext.keys():
- if sub in xlink[5:semicolon]:
+ if sub in xlink[5:semicolon].lower():
fileext=mimesubext[sub]
path=path+fileext;
- break
+ if (not os.path.isabs(path)):
+ if os.name == 'nt':
+ path = os.path.join(os.environ['USERPROFILE'],path)
+ else:
+ path = os.path.join(os.path.expanduser("~"),path)
+ inkex.errormsg(_('Image extracted to: %s') % path)
+ break
#save
data = base64.decodestring(xlink[comma:])
open(path,'wb').write(data)
node.set(inkex.addNS('href','xlink'),os.path.realpath(path)) #absolute for making in-mem cycles work
else:
- inkex.debug('Difficulty finding the image data.')
+ inkex.errormsg(_('Unable to find image data.'))
break
-e = MyEffect()
-e.affect()
+if __name__ == '__main__':
+ e = MyEffect()
+ e.affect()
-# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99