Commit 7bfa6228 authored by Guillaume Seguin's avatar Guillaume Seguin

Reset svg to an older version as well

parent 3d0f4985
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" """
""" """
import wx import wx
def AddEllipticalArc(self, x, y, w, h, startAngle, endAngle, clockwise = False): def AddEllipticalArc(self, x, y, w, h, startAngle, endAngle, clockwise=False):
""" Draws an arc of an ellipse within bounding rect (x, y, w, h) """ Draws an arc of an ellipse within bounding rect (x,y,w,h)
from startArc to endArc (in radians, relative to the horizontal line of the eclipse)""" from startArc to endArc (in radians, relative to the horizontal line of the eclipse)"""
if True: if True:
...@@ -55,3 +40,4 @@ if not hasattr(wx.GraphicsPath, "AddEllipticalArc"): ...@@ -55,3 +40,4 @@ if not hasattr(wx.GraphicsPath, "AddEllipticalArc"):
wx.GraphicsPath.AddEllipticalArc = AddEllipticalArc wx.GraphicsPath.AddEllipticalArc = AddEllipticalArc
del AddEllipticalArc del AddEllipticalArc
\ No newline at end of file
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" """
Parsers for specific attributes Parsers for specific attributes
""" """
...@@ -37,7 +22,7 @@ colorDeclaration = none | currentColor | colourValue ...@@ -37,7 +22,7 @@ colorDeclaration = none | currentColor | colourValue
urlEnd = ( urlEnd = (
Literal(")").suppress() + Literal(")").suppress() +
Optional(Group(colorDeclaration), default = ()) + Optional(Group(colorDeclaration), default=()) +
StringEnd() StringEnd()
) )
...@@ -45,12 +30,12 @@ url = ( ...@@ -45,12 +30,12 @@ url = (
CaselessLiteral("URL") CaselessLiteral("URL")
+ +
Literal("(").suppress()+ Literal("(").suppress()+
Group(SkipTo(urlEnd, include = True).setParseAction(parsePossibleURL)) Group(SkipTo(urlEnd, include=True).setParseAction(parsePossibleURL))
) )
#paint value will parse into a (type, details) tuple. #paint value will parse into a (type, details) tuple.
#For none and currentColor, the details tuple will be the empty tuple #For none and currentColor, the details tuple will be the empty tuple
#for CSS color declarations, it will be (type, (R, G, B)) #for CSS color declarations, it will be (type, (R,G,B))
#for URLs, it will be ("URL", ((url tuple), fallback)) #for URLs, it will be ("URL", ((url tuple), fallback))
#The url tuple will be as returned by urlparse.urlsplit, and can be #The url tuple will be as returned by urlparse.urlsplit, and can be
#an empty tuple if the parser has an error #an empty tuple if the parser has an error
......
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import from __future__ import absolute_import
from .transform import transformList from .transform import transformList
from .inline import inlineStyle from .inline import inlineStyle
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" CSS at-rules""" """ CSS at-rules"""
from pyparsing import Literal, Combine from pyparsing import Literal, Combine
......
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" """
CSS blocks CSS blocks
""" """
...@@ -20,3 +5,4 @@ ...@@ -20,3 +5,4 @@
from pyparsing import nestedExpr from pyparsing import nestedExpr
block = nestedExpr(opener="{", closer="}") block = nestedExpr(opener="{", closer="}")
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" """
Parsing for CSS colour values. Parsing for CSS colour values.
Supported formats: Supported formats:
......
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" Parse CSS identifiers. More complicated than it sounds""" """ Parse CSS identifiers. More complicated than it sounds"""
from pyparsing import Word, Literal, Regex, Combine, Optional, White, oneOf, ZeroOrMore from pyparsing import Word, Literal, Regex, Combine, Optional, White, oneOf, ZeroOrMore
......
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" Parser for inline CSS in style attributes """ """ Parser for inline CSS in style attributes """
def inlineStyle(styleString): def inlineStyle(styleString):
......
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" """
Parsing for CSS and CSS-style values, such as transform and filter attributes. Parsing for CSS and CSS-style values, such as transform and filter attributes.
""" """
......
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" """
Parser for various kinds of CSS values as per CSS2 spec section 4.3 Parser for various kinds of CSS values as per CSS2 spec section 4.3
""" """
......
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" """
SVGDocument SVGDocument
""" """
...@@ -25,26 +10,26 @@ from functools import wraps ...@@ -25,26 +10,26 @@ from functools import wraps
import pathdata import pathdata
import css import css
from css.colour import colourValue from svg.css.colour import colourValue
from css import values from svg.css import values
from attributes import paintValue from attributes import paintValue
document = """<?xml version = "1.0" standalone = "no"?> document = """<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width = "4cm" height = "4cm" viewBox = "0 0 400 400" <svg width="4cm" height="4cm" viewBox="0 0 400 400"
xmlns = "http://www.w3.org/2000/svg" version = "1.1"> xmlns="http://www.w3.org/2000/svg" version="1.1">
<title>Example triangle01- simple example of a 'path'</title> <title>Example triangle01- simple example of a 'path'</title>
<desc>A path that draws a triangle</desc> <desc>A path that draws a triangle</desc>
<rect x = "1" y = "1" width = "398" height = "398" <rect x="1" y="1" width="398" height="398"
fill = "none" stroke = "blue" /> fill="none" stroke="blue" />
<path d = "M 100 100 L 300 100 L 200 300 z" <path d="M 100 100 L 300 100 L 200 300 z"
fill = "red" stroke = "blue" stroke-width = "3" /> fill="red" stroke="blue" stroke-width="3" />
</svg>""" </svg>"""
makePath = lambda: wx.GraphicsRenderer_GetDefaultRenderer().CreatePath() makePath = lambda: wx.GraphicsRenderer_GetDefaultRenderer().CreatePath()
def attrAsFloat(node, attr, defaultValue = "0"): def attrAsFloat(node, attr, defaultValue="0"):
val = node.get(attr, defaultValue) val = node.get(attr, defaultValue)
#TODO: process stuff like "inherit" by walking back up the nodes #TODO: process stuff like "inherit" by walking back up the nodes
#fast path optimization - if it's a valid float, don't #fast path optimization - if it's a valid float, don't
...@@ -54,7 +39,7 @@ def attrAsFloat(node, attr, defaultValue = "0"): ...@@ -54,7 +39,7 @@ def attrAsFloat(node, attr, defaultValue = "0"):
except ValueError: except ValueError:
return valueToPixels(val) return valueToPixels(val)
def valueToPixels(val, defaultUnits = "px"): def valueToPixels(val, defaultUnits="px"):
#TODO manage default units #TODO manage default units
from pyparsing import ParseException from pyparsing import ParseException
try: try:
...@@ -190,14 +175,14 @@ class SVGDocument(object): ...@@ -190,14 +175,14 @@ class SVGDocument(object):
) )
if transform == 'skewX': if transform == 'skewX':
matrix = wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix( matrix = wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix(
1, 0, math.tan(math.radians(args[0])), 1, 0, 0 1,0,math.tan(math.radians(args[0])),1,0,0
) )
ops.append( ops.append(
(wx.GraphicsContext.ConcatTransform, (matrix,)) (wx.GraphicsContext.ConcatTransform, (matrix,))
) )
if transform == 'skewY': if transform == 'skewY':
matrix = wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix( matrix = wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix(
1, math.tan(math.radians(args[0])), 0, 1, 0, 0 1,math.tan(math.radians(args[0])),0,1,0,0
) )
ops.append( ops.append(
(wx.GraphicsContext.ConcatTransform, (matrix,)) (wx.GraphicsContext.ConcatTransform, (matrix,))
...@@ -246,7 +231,7 @@ class SVGDocument(object): ...@@ -246,7 +231,7 @@ class SVGDocument(object):
def addTextToDocument(self, node): def addTextToDocument(self, node):
x, y = [attrAsFloat(node, attr) for attr in ('x', 'y')] x, y = [attrAsFloat(node, attr) for attr in ('x', 'y')]
def DoDrawText(context, text, x, y, brush = wx.NullGraphicsBrush): def DoDrawText(context, text, x, y, brush=wx.NullGraphicsBrush):
#SVG spec appears to originate text from the bottom #SVG spec appears to originate text from the bottom
#rather than the top as with our API. This function #rather than the top as with our API. This function
#will measure and then re-orient the text as needed. #will measure and then re-orient the text as needed.
...@@ -274,7 +259,7 @@ class SVGDocument(object): ...@@ -274,7 +259,7 @@ class SVGDocument(object):
rx = node.get('rx') rx = node.get('rx')
ry = node.get('ry') ry = node.get('ry')
if not (w and h): if not (w and h):
path.MoveToPoint(x, y) #keep the current point correct path.MoveToPoint(x,y) #keep the current point correct
return return
if rx or ry: if rx or ry:
if rx and ry: if rx and ry:
...@@ -464,7 +449,7 @@ class SVGDocument(object): ...@@ -464,7 +449,7 @@ class SVGDocument(object):
pen.SetJoin(joinmap.get(self.state.get('stroke-linejoin', None), wx.JOIN_MITER)) pen.SetJoin(joinmap.get(self.state.get('stroke-linejoin', None), wx.JOIN_MITER))
return wx.GraphicsRenderer_GetDefaultRenderer().CreatePen(pen) return wx.GraphicsRenderer_GetDefaultRenderer().CreatePen(pen)
def getBrushFromState(self, path = None): def getBrushFromState(self, path=None):
brushcolour = self.state.get('fill', 'black').strip() brushcolour = self.state.get('fill', 'black').strip()
type, details = paintValue.parseString(brushcolour) type, details = paintValue.parseString(brushcolour)
if type == "URL": if type == "URL":
...@@ -480,29 +465,29 @@ class SVGDocument(object): ...@@ -480,29 +465,29 @@ class SVGDocument(object):
box = path.GetBox() box = path.GetBox()
x, y, w, h = box.Get() x, y, w, h = box.Get()
return wx.GraphicsRenderer.GetDefaultRenderer().CreateLinearGradientBrush( return wx.GraphicsRenderer.GetDefaultRenderer().CreateLinearGradientBrush(
x, y, x+w, y+h, wx.Colour(0, 0, 255, 128), wx.RED x,y,x+w,y+h,wx.Colour(0,0,255,128), wx.RED
) )
elif element.tag == '{http://www.w3.org/2000/svg}radialGradient': elif element.tag == '{http://www.w3.org/2000/svg}radialGradient':
box = path.GetBox() box = path.GetBox()
x, y, w, h = box.Get() x, y, w, h = box.Get()
#print w #print w
mx = wx.GraphicsRenderer.GetDefaultRenderer().CreateMatrix(x, y, w, h) mx = wx.GraphicsRenderer.GetDefaultRenderer().CreateMatrix(x,y,w,h)
cx, cy = mx.TransformPoint(0.5, 0.5) cx, cy = mx.TransformPoint(0.5, 0.5)
fx, fy = cx, cy fx, fy = cx, cy
return wx.GraphicsRenderer.GetDefaultRenderer().CreateRadialGradientBrush( return wx.GraphicsRenderer.GetDefaultRenderer().CreateRadialGradientBrush(
cx, cy, cx,cy,
fx, fy, fx,fy,
(max(w, h))/2, (max(w,h))/2,
wx.Colour(0, 0, 255, 128), wx.RED wx.Colour(0,0,255,128), wx.RED
) )
else: else:
#invlid gradient specified #invlid gradient specified
return wx.NullBrush return wx.NullBrush
r, g, b = 0, 0, 0 r,g,b = 0,0,0
if type == 'CURRENTCOLOR': if type == 'CURRENTCOLOR':
type, details = paintValue.parseString(self.state.get('color', 'none')) type, details = paintValue.parseString(self.state.get('color', 'none'))
if type == 'RGB': if type == 'RGB':
r, g, b = details r,g,b = details
elif type == "NONE": elif type == "NONE":
return wx.NullBrush return wx.NullBrush
opacity = self.state.get('fill-opacity', self.state.get('opacity', '1')) opacity = self.state.get('fill-opacity', self.state.get('opacity', '1'))
...@@ -514,9 +499,9 @@ class SVGDocument(object): ...@@ -514,9 +499,9 @@ class SVGDocument(object):
#be created every time anyway in order to pass them, #be created every time anyway in order to pass them,
#defeating the purpose of the cache #defeating the purpose of the cache
try: try:
return SVGDocument.brushCache[(r, g, b, a)] return SVGDocument.brushCache[(r,g,b,a)]
except KeyError: except KeyError:
return SVGDocument.brushCache.setdefault((r, g, b, a), wx.Brush(wx.Colour(r, g, b, a))) return SVGDocument.brushCache.setdefault((r,g,b,a), wx.Brush(wx.Colour(r,g,b,a)))
def resolveURL(self, urlData): def resolveURL(self, urlData):
...@@ -586,7 +571,7 @@ class SVGDocument(object): ...@@ -586,7 +571,7 @@ class SVGDocument(object):
#~ cp = path.GetCurrentPoint() #~ cp = path.GetCurrentPoint()
#~ path.AddCircle(c1x, c1y, 5) #~ path.AddCircle(c1x, c1y, 5)
#~ path.AddCircle(c2x, c2y, 3) #~ path.AddCircle(c2x, c2y, 3)
#~ path.AddCircle(x, y, 7) #~ path.AddCircle(x,y, 7)
#~ path.MoveToPoint(cp) #~ path.MoveToPoint(cp)
#~ print "C", control1, control2, endpoint #~ print "C", control1, control2, endpoint
...@@ -599,7 +584,7 @@ class SVGDocument(object): ...@@ -599,7 +584,7 @@ class SVGDocument(object):
control1 = reflectPoint(self.lastControl, path.GetCurrentPoint()) control1 = reflectPoint(self.lastControl, path.GetCurrentPoint())
else: else:
control1 = path.GetCurrentPoint() control1 = path.GetCurrentPoint()
#~ print "S", self.lastControl, ":", control1, control2, endpoint #~ print "S", self.lastControl,":",control1, control2, endpoint
self.lastControl = control2 self.lastControl = control2
path.AddCurveToPoint( path.AddCurveToPoint(
control1, control1,
...@@ -607,7 +592,7 @@ class SVGDocument(object): ...@@ -607,7 +592,7 @@ class SVGDocument(object):
endpoint endpoint
) )
elif type == "Q": elif type == "Q":
(cx, cy), (x, y) = map(normalizePoint, arg) (cx, cy), (x,y) = map(normalizePoint, arg)
self.lastControlQ = (cx, cy) self.lastControlQ = (cx, cy)
path.AddQuadCurveToPoint(cx, cy, x, y) path.AddQuadCurveToPoint(cx, cy, x, y)
elif type == "T": elif type == "T":
...@@ -622,12 +607,12 @@ class SVGDocument(object): ...@@ -622,12 +607,12 @@ class SVGDocument(object):
elif type == "V": elif type == "V":
_, y = normalizePoint((0, arg)) _, y = normalizePoint((0, arg))
x, _ = path.GetCurrentPoint() x, _ = path.GetCurrentPoint()
path.AddLineToPoint(x, y) path.AddLineToPoint(x,y)
elif type == "H": elif type == "H":
x, _ = normalizePoint((arg, 0)) x, _ = normalizePoint((arg, 0))
_, y = path.GetCurrentPoint() _, y = path.GetCurrentPoint()
path.AddLineToPoint(x, y) path.AddLineToPoint(x,y)
elif type == "A": elif type == "A":
#wxGC currently only supports circular arcs, #wxGC currently only supports circular arcs,
...@@ -640,14 +625,14 @@ class SVGDocument(object): ...@@ -640,14 +625,14 @@ class SVGDocument(object):
(x, y) #endpoint on the arc (x, y) #endpoint on the arc
) = arg ) = arg
x, y = normalizePoint((x, y)) x, y = normalizePoint((x,y))
cx, cy = path.GetCurrentPoint() cx, cy = path.GetCurrentPoint()
if (cx, cy) == (x, y): if (cx, cy) == (x, y):
return #noop return #noop
if (rx == 0 or ry == 0): if (rx == 0 or ry == 0):
#no radius is effectively a line #no radius is effectively a line
path.AddLineToPoint(x, y) path.AddLineToPoint(x,y)
return return
#find the center point for the ellipse #find the center point for the ellipse
...@@ -700,7 +685,7 @@ class SVGDocument(object): ...@@ -700,7 +685,7 @@ class SVGDocument(object):
path.MoveToPoint(x, y) path.MoveToPoint(x, y)
#~ npath = makePath() #~ npath = makePath()
#~ npath.AddEllipticalArc(cnx-rx, cny-ry, rx*2, ry*2, firstArc, lastArc, False) #~ npath.AddEllipticalArc(cnx-rx, cny-ry, rx*2, ry*2, firstArc, lastArc, False)
#~ npath.MoveToPoint(x, y) #~ npath.MoveToPoint(x,y)
#~ path.AddPath(npath) #~ path.AddPath(npath)
elif type == 'Z': elif type == 'Z':
......
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
""" """
SVG path data parser SVG path data parser
...@@ -42,12 +27,12 @@ class CaselessPreservingLiteral(CaselessLiteral): ...@@ -42,12 +27,12 @@ class CaselessPreservingLiteral(CaselessLiteral):
instead of as defined. instead of as defined.
""" """
def __init__( self, matchString ): def __init__( self, matchString ):
super(CaselessPreservingLiteral, self).__init__( matchString.upper() ) super(CaselessPreservingLiteral,self).__init__( matchString.upper() )
self.name = "'%s'" % matchString self.name = "'%s'" % matchString
self.errmsg = "Expected " + self.name self.errmsg = "Expected " + self.name
self.myException.msg = self.errmsg self.myException.msg = self.errmsg
def parseImpl( self, instring, loc, doActions = True ): def parseImpl( self, instring, loc, doActions=True ):
test = instring[ loc:loc+self.matchLen ] test = instring[ loc:loc+self.matchLen ]
if test.upper() == self.match: if test.upper() == self.match:
return loc+self.matchLen, test return loc+self.matchLen, test
...@@ -132,7 +117,7 @@ ellipticalArcArgument = Group( ...@@ -132,7 +117,7 @@ ellipticalArcArgument = Group(
arcRadius + maybeComma + #rx, ry arcRadius + maybeComma + #rx, ry
number + maybeComma +#rotation number + maybeComma +#rotation
arcFlags + #large-arc-flag, sweep-flag arcFlags + #large-arc-flag, sweep-flag
coordinatePair #(x, y) coordinatePair #(x,y)
) )
...@@ -204,3 +189,5 @@ if __name__ == '__main__': ...@@ -204,3 +189,5 @@ if __name__ == '__main__':
#~ from tests.test_pathdata import * #~ from tests.test_pathdata import *
#~ unittest.main() #~ unittest.main()
profile() profile()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment