summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 33e1ee8)
raw | patch | inline | side by side (parent: 33e1ee8)
author | sasilver <sasilver@users.sourceforge.net> | |
Wed, 9 Jul 2008 17:51:46 +0000 (17:51 +0000) | ||
committer | sasilver <sasilver@users.sourceforge.net> | |
Wed, 9 Jul 2008 17:51:46 +0000 (17:51 +0000) |
1) Cope with missing xlink:href. (Fixes bug 246724.)
2) Don't ignore images with filenames that begin with "data".
3) Remove an unused line.
4) Suppress part of an error message in cases where it makes no sense.
2) Don't ignore images with filenames that begin with "data".
3) Remove an unused line.
4) Suppress part of an error message in cases where it makes no sense.
share/extensions/embedimage.py | patch | blob | history |
index ab903a18e90919c0595e8462bc4d3fee9672651a..93472b325104621dce2dc10a6a7f9f35b924ee2f 100644 (file)
def embedImage(self, node):
xlink = node.get(inkex.addNS('href','xlink'))
- if (xlink[:4]!='data'):
+ if xlink is None or xlink[:5] != 'data:':
absref=node.get(inkex.addNS('absref','sodipodi'))
href=xlink
- svg=self.document.getroot().xpath('/svg:svg', namespaces=inkex.NSS)[0]
path=''
#path selection strategy:
# 1. href if absolute
if (not os.path.isfile(path)):
if (absref != None):
path=absref
+
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:
+ inkex.errormsg(_("Sorry we could not locate %s") % path)
+
if (os.path.isfile(path)):
file = open(path,"rb").read()
embed=True
del node.attrib[inkex.addNS('absref',u'sodipodi')]
else:
inkex.errormsg(_("%s is not of type image/png, image/jpeg, image/bmp, image/gif, image/tiff, or image/x-icon") % path)
- else:
- inkex.errormsg(_("Sorry we could not locate %s") % path)
if __name__ == '__main__':
e = Embedder()