Sorry, but I won't be able to work on this until Thursday-ish or the
weekend. I will update the bug once I get something working in the
script.
Jeff
On Tue, Mar 23, 2010 at 9:37 AM, Matt Sarjent <email address hidden> wrote:
> That's good for me. When fixed, is it possible for me to get it? Do you
> have an idea when it would be fixed?
>
> --
> SaveAs Optimized SVG error "AttributeError: 'SVGLength' object has no attribute 'units'"
> https://bugs.launchpad.net/bugs/541889
> You received this bug notification because you are the registrant for
> Scour.
>
> Status in Inkscape: A Vector Drawing Tool: New
> Status in Scour - Cleaning SVG Files: New
>
> Bug description:
> Hi, love Inkscape, especially using python :-) although i'm post-processing/parsing svg with beautifulSoup.
>
> 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\share\extensions\scour.inkscape.py", line 6, in <module>
> sys.stdout.write(scourString(input.read()).encode("UTF-8"))
> File "C:\Program Files\Inkscape\share\extensions\scour.py", line 2245, in scourString
> cleanPolygon(polygon)
> File "C:\Program Files\Inkscape\share\extensions\scour.py", line 1803, in cleanPolygon
> pts = parseListOfPoints(elem.getAttribute('points'))
> File "C:\Program Files\Inkscape\share\extensions\scour.py", line 1790, in parseListOfPoints
> 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.match(str)
> if scinum != None:
> # this will always match, no need to check it
> numMatch = number.match(str)
> expMatch = sciExponent.search(str, numMatch.start(0))
> self.value = (float(numMatch.group(0)) *
> 10 ** float(expMatch.group(1)))
> unitBegin = expMatch.end(1)
> else:
> # unit or invalid
> numMatch = number.match(str)
> if numMatch != None:
> self.value = float(numMatch.group(0))
> 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(unitMatch.group(0))
> 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.
>
>
>
Matt,
Sorry, but I won't be able to work on this until Thursday-ish or the
weekend. I will update the bug once I get something working in the
script.
Jeff
On Tue, Mar 23, 2010 at 9:37 AM, Matt Sarjent <email address hidden> wrote: /bugs.launchpad .net/bugs/ 541889 /parsing svg with beautifulSoup. share\extension s\scour. inkscape. py", line 6, in <module> write(scourStri ng(input. read()) .encode( "UTF-8" )) share\extension s\scour. py", line 2245, in scourString polygon) share\extension s\scour. py", line 1803, in cleanPolygon ts(elem. getAttribute( 'points' )) share\extension s\scour. py", line 1790, in parseListOfPoints match(str) search( str, numMatch.start(0)) numMatch. group(0) ) * group(1) )) group(0) ) unitMatch. group(0) )
> That's good for me. When fixed, is it possible for me to get it? Do you
> have an idea when it would be fixed?
>
> --
> SaveAs Optimized SVG error "AttributeError: 'SVGLength' object has no attribute 'units'"
> https:/
> You received this bug notification because you are the registrant for
> Scour.
>
> Status in Inkscape: A Vector Drawing Tool: New
> Status in Scour - Cleaning SVG Files: New
>
> 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.stdout.
> File "C:\Program Files\Inkscape\
> cleanPolygon(
> 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.
>
>
>