SaveAs Optimized SVG error "AttributeError: 'SVGLength' object has no attribute 'units'"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
Fix Released
|
Low
|
jazzynico | ||
Scour |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Hi, love Inkscape, especially using python :-) although i'm post-processing
I have been trying to save a file with the fill attributes separate to the style attributes so i tried to save using the "Optimized SVG" file type option. Unfortunately i keep on getting the error
Traceback (most recent call last):
File "C:\Program Files\Inkscape\
sys.
File "C:\Program Files\Inkscape\
cleanPolygo
File "C:\Program Files\Inkscape\
pts = parseListOfPoin
File "C:\Program Files\Inkscape\
if x.units != Unit.NONE or y.units != Unit.NONE: return []
AttributeError: 'SVGLength' object has no attribute 'units'
so i traced it through to the scour.py where the SVGLength doesn't set the self.units in all cases after a ValueError in thrown.
so i added in the extra case giving the new code
class SVGLength(object):
def __init__(self, str):
try: # simple unitless and no scientific notation
self.value = float(str)
if int(self.value) == self.value:
self.value = int(self.value)
self.units = Unit.NONE
except ValueError:
# we know that the length string has an exponent, a unit, both or is invalid
# parse out number, exponent and unit
self.value = 0
unitBegin = 0
scinum = scinumber.
if scinum != None:
# this will always match, no need to check it
numMatch = number.match(str)
expMatch = sciExponent.
self.value = (float(
10 ** float(expMatch.
unitBegin = expMatch.end(1)
else:
# unit or invalid
numMatch = number.match(str)
if numMatch != None:
self.value = float(numMatch.
unitBegin = numMatch.end(0)
if int(self.value) == self.value:
self.value = int(self.value)
if unitBegin != 0 :
unitMatch = unit.search(str, unitBegin)
if unitMatch != None :
self.units = Unit.get(
else: # new added code
self.units = Unit.INVALID # new added code
# invalid
else:
# TODO: this needs to set the default for the given attribute (how?)
self.value = 0
self.units = Unit.INVALID
Unfortunately i am not allowed to give you the original file until after 6th May. After that, give me an email if you need the file.
Related branches
Changed in scour: | |
status: | Fix Committed → Fix Released |
Changed in inkscape: | |
status: | Fix Committed → Fix Released |
Hi,
Which inkscape version do you use?
Could you please try to extract the part of your file which produces this bug, so that we can try to reproduce it?