diff options
| -rwxr-xr-x | share/extensions/inkex.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 2517c7e04..6eb229885 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -207,7 +207,7 @@ class Effect: x = self.unittouu( xattr[0] + 'px' ) y = self.unittouu( yattr[0] + 'px') doc_height = self.unittouu(self.document.getroot().get('height')) - if x and y: + if x and y and doc_height is not None: self.view_center = (float(x), doc_height - float(y)) # FIXME: y-coordinate flip, eliminate it when it's gone in Inkscape def getselected(self): @@ -340,19 +340,22 @@ class Effect: unit = re.compile('(%s)$' % '|'.join(self.__uuconv.keys())) param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)') - p = param.match(string) - u = unit.search(string) - if p: - retval = float(p.string[p.start():p.end()]) + if string is not None: + p = param.match(string) + u = unit.search(string) + if p: + retval = float(p.string[p.start():p.end()]) + else: + retval = 0.0 + if u: + try: + return retval * (self.__uuconv[u.string[u.start():u.end()]] / self.__uuconv[self.getDocumentUnit()]) + except KeyError: + pass + else: # default assume 'px' unit + return retval / self.__uuconv[self.getDocumentUnit()] else: - retval = 0.0 - if u: - try: - return retval * (self.__uuconv[u.string[u.start():u.end()]] / self.__uuconv[self.getDocumentUnit()]) - except KeyError: - pass - else: # default assume 'px' unit - return retval / self.__uuconv[self.getDocumentUnit()] + retval = None return retval |
