about summary refs log tree commit diff
path: root/wqflask/utility/svg.py
diff options
context:
space:
mode:
authorBonfaceKilz2021-04-30 12:26:19 +0300
committerBonfaceKilz2021-04-30 13:45:15 +0300
commit406eb27859cca232a562c722cbbd37aca2e3be84 (patch)
treeba3fba783e33cc56c535b68bd64d757bc6cde608 /wqflask/utility/svg.py
parentc7e661b8ff9f70955418fbc4527378904beb0cf4 (diff)
downloadgenenetwork2-406eb27859cca232a562c722cbbd37aca2e3be84.tar.gz
autopep8: Fix E301,E302,E303,E304,E305,E306
Diffstat (limited to 'wqflask/utility/svg.py')
-rw-r--r--wqflask/utility/svg.py67
1 files changed, 65 insertions, 2 deletions
diff --git a/wqflask/utility/svg.py b/wqflask/utility/svg.py
index 4c478c36..f5ef81e1 100644
--- a/wqflask/utility/svg.py
+++ b/wqflask/utility/svg.py
@@ -459,11 +459,13 @@ class rect(SVGelement):
         if stroke_width != None:
             self.attributes['stroke-width'] = stroke_width
 
+
 class ellipse(SVGelement):
     """e=ellipse(rx,ry,x,y,fill,stroke,stroke_width,**args)
 
     an ellipse is defined as a center and a x and y radius.
     """
+
     def __init__(self, cx=None, cy=None, rx=None, ry=None,fill=None,stroke=None,stroke_width=None,**args):
         if rx == None or ry == None:
             raise ValueError('both rx and ry are required')
@@ -486,6 +488,7 @@ class circle(SVGelement):
 
     The circle creates an element using a x, y and radius values eg
     """
+
     def __init__(self, cx=None, cy=None, r=None, fill=None,stroke=None,stroke_width=None,**args):
         if r == None:
             raise ValueError('r is required')
@@ -501,20 +504,24 @@ class circle(SVGelement):
         if stroke_width != None:
             self.attributes['stroke-width'] = stroke_width
 
+
 class point(circle):
     """p=point(x,y,color)
 
     A point is defined as a circle with a size 1 radius. It may be more efficient to use a
     very small rectangle if you use many points because a circle is difficult to render.
     """
+
     def __init__(self, x, y, fill='black', **args):
         circle.__init__(self, x, y, 1, fill, **args)
 
+
 class line(SVGelement):
     """l=line(x1,y1,x2,y2,stroke,stroke_width,**args)
 
     A line is defined by a begin x,y pair and an end x,y pair
     """
+
     def __init__(self, x1=None, y1=None, x2=None, y2=None,stroke=None,stroke_width=None,**args):
         SVGelement.__init__(self, 'line', **args)
         if x1 != None:
@@ -530,11 +537,13 @@ class line(SVGelement):
         if stroke != None:
             self.attributes['stroke'] = stroke
 
+
 class polyline(SVGelement):
     """pl=polyline([[x1,y1],[x2,y2],...],fill,stroke,stroke_width,**args)
 
     a polyline is defined by a list of xy pairs
     """
+
     def __init__(self, points, fill=None, stroke=None, stroke_width=None,**args):
         SVGelement.__init__(self, 'polyline', {'points': _xypointlist(points)}, **args)
         if fill != None:
@@ -544,11 +553,13 @@ class polyline(SVGelement):
         if stroke != None:
             self.attributes['stroke'] = stroke
 
+
 class polygon(SVGelement):
     """pl=polyline([[x1,y1],[x2,y2],...],fill,stroke,stroke_width,**args)
 
     a polygon is defined by a list of xy pairs
     """
+
     def __init__(self, points, fill=None, stroke=None, stroke_width=None,**args):
         SVGelement.__init__(self, 'polygon', {'points': _xypointlist(points)}, **args)
         if fill != None:
@@ -558,11 +569,13 @@ class polygon(SVGelement):
         if stroke != None:
             self.attributes['stroke'] = stroke
 
+
 class path(SVGelement):
     """p=path(path,fill,stroke,stroke_width,**args)
 
     a path is defined by a path object and optional width, stroke and fillcolor
     """
+
     def __init__(self, pathdata, fill=None, stroke=None, stroke_width=None,id=None,**args):
         SVGelement.__init__(self, 'path', {'d': str(pathdata)}, **args)
         if stroke != None:
@@ -580,6 +593,7 @@ class text(SVGelement):
 
     a text element can bge used for displaying text on the screen
     """
+
     def __init__(self, x=None, y=None, text=None, font_size=None,font_family=None,text_anchor=None,**args):
         SVGelement.__init__(self, 'text', **args)
         if x != None:
@@ -601,11 +615,13 @@ class textpath(SVGelement):
 
     a textpath places a text on a path which is referenced by a link.
     """
+
     def __init__(self, link, text=None, **args):
         SVGelement.__init__(self, 'textPath', {'xlink:href': link}, **args)
         if text != None:
             self.text = text
 
+
 class pattern(SVGelement):
     """p=pattern(x,y,width,height,patternUnits,**args)
 
@@ -613,6 +629,7 @@ class pattern(SVGelement):
     graphic object which can be replicated ("tiled") at fixed intervals
     in x and y to cover the areas to be painted.
     """
+
     def __init__(self, x=None, y=None, width=None, height=None,patternUnits=None,**args):
         SVGelement.__init__(self, 'pattern', **args)
         if x != None:
@@ -626,34 +643,40 @@ class pattern(SVGelement):
         if patternUnits != None:
             self.attributes['patternUnits'] = patternUnits
 
+
 class title(SVGelement):
     """t=title(text,**args)
 
     a title is a text element. The text is displayed in the title bar
     add at least one to the root svg element
     """
+
     def __init__(self, text=None, **args):
         SVGelement.__init__(self, 'title', **args)
         if text != None:
             self.text = text
 
+
 class description(SVGelement):
     """d=description(text,**args)
 
     a description can be added to any element and is used for a tooltip
     Add this element before adding other elements.
     """
+
     def __init__(self, text=None, **args):
         SVGelement.__init__(self, 'desc', **args)
         if text != None:
             self.text = text
 
+
 class lineargradient(SVGelement):
     """lg=lineargradient(x1,y1,x2,y2,id,**args)
 
     defines a lineargradient using two xy pairs.
     stop elements van be added to define the gradient colors.
     """
+
     def __init__(self, x1=None, y1=None, x2=None, y2=None,id=None,**args):
         SVGelement.__init__(self, 'linearGradient', **args)
         if x1 != None:
@@ -667,12 +690,14 @@ class lineargradient(SVGelement):
         if id != None:
             self.attributes['id'] = id
 
+
 class radialgradient(SVGelement):
     """rg=radialgradient(cx,cy,r,fx,fy,id,**args)
 
     defines a radial gradient using a outer circle which are defined by a cx,cy and r and by using a focalpoint.
     stop elements van be added to define the gradient colors.
     """
+
     def __init__(self, cx=None, cy=None, r=None, fx=None,fy=None,id=None,**args):
         SVGelement.__init__(self, 'radialGradient', **args)
         if cx != None:
@@ -688,21 +713,25 @@ class radialgradient(SVGelement):
         if id != None:
             self.attributes['id'] = id
 
+
 class stop(SVGelement):
     """st=stop(offset,stop_color,**args)
 
     Puts a stop color at the specified radius
     """
+
     def __init__(self, offset, stop_color=None, **args):
         SVGelement.__init__(self, 'stop', {'offset': offset}, **args)
         if stop_color != None:
             self.attributes['stop-color'] = stop_color
 
+
 class style(SVGelement):
     """st=style(type,cdata=None,**args)
 
     Add a CDATA element to this element for defing in line stylesheets etc..
     """
+
     def __init__(self, type, cdata=None, **args):
         SVGelement.__init__(self, 'style', {'type': type}, cdata=cdata, **args)
 
@@ -712,6 +741,7 @@ class image(SVGelement):
 
     adds an image to the drawing. Supported formats are .png, .jpg and .svg.
     """
+
     def __init__(self, url, x=None, y=None, width=None,height=None,**args):
         if width == None or height == None:
             raise ValueError('both height and width are required')
@@ -721,11 +751,13 @@ class image(SVGelement):
         if y != None:
             self.attributes['y'] = y
 
+
 class cursor(SVGelement):
     """c=cursor(url,**args)
 
     defines a custom cursor for a element or a drawing
     """
+
     def __init__(self, url, **args):
         SVGelement.__init__(self, 'cursor', {'xlink:href': url}, **args)
 
@@ -736,6 +768,7 @@ class marker(SVGelement):
     defines a marker which can be used as an endpoint for a line or other pathtypes
     add an element to it which should be used as a marker.
     """
+
     def __init__(self, id=None, viewBox=None, refx=None, refy=None,markerWidth=None,markerHeight=None,**args):
         SVGelement.__init__(self, 'marker', **args)
         if id != None:
@@ -751,17 +784,20 @@ class marker(SVGelement):
         if markerHeight != None:
             self.attributes['markerHeight'] = markerHeight
 
+
 class group(SVGelement):
     """g=group(id,**args)
 
     a group is defined by an id and is used to contain elements
     g.addElement(SVGelement)
     """
+
     def __init__(self, id=None, **args):
         SVGelement.__init__(self, 'g', **args)
         if id != None:
             self.attributes['id'] = id
 
+
 class symbol(SVGelement):
     """sy=symbol(id,viewbox,**args)
 
@@ -778,14 +814,17 @@ class symbol(SVGelement):
         if viewBox != None:
             self.attributes['viewBox'] = _viewboxlist(viewBox)
 
+
 class defs(SVGelement):
     """d=defs(**args)
 
     container for defining elements
     """
+
     def __init__(self, **args):
         SVGelement.__init__(self, 'defs', **args)
 
+
 class switch(SVGelement):
     """sw=switch(**args)
 
@@ -793,6 +832,7 @@ class switch(SVGelement):
     requiredFeatures, requiredExtensions and systemLanguage.
     Refer to the SVG specification for details.
     """
+
     def __init__(self, **args):
         SVGelement.__init__(self, 'switch', **args)
 
@@ -802,6 +842,7 @@ class use(SVGelement):
 
     references a symbol by linking to its id and its position, height and width
     """
+
     def __init__(self, link, x=None, y=None, width=None,height=None,**args):
         SVGelement.__init__(self, 'use', {'xlink:href': link}, **args)
         if x != None:
@@ -821,32 +862,39 @@ class link(SVGelement):
     a link  is defined by a hyperlink. add elements which have to be linked
     a.addElement(SVGelement)
     """
+
     def __init__(self, link='', **args):
         SVGelement.__init__(self, 'a', {'xlink:href': link}, **args)
 
+
 class view(SVGelement):
     """v=view(id,**args)
 
     a view can be used to create a view with different attributes"""
+
     def __init__(self, id=None, **args):
         SVGelement.__init__(self, 'view', **args)
         if id != None:
             self.attributes['id'] = id
 
+
 class script(SVGelement):
     """sc=script(type,type,cdata,**args)
 
     adds a script element which contains CDATA to the SVG drawing
 
     """
+
     def __init__(self, type, cdata=None, **args):
         SVGelement.__init__(self, 'script', {'type': type}, cdata=cdata, **args)
 
+
 class animate(SVGelement):
     """an=animate(attribute,from,to,during,**args)
 
     animates an attribute.
     """
+
     def __init__(self, attribute, fr=None, to=None, dur=None,**args):
         SVGelement.__init__(self, 'animate', {'attributeName': attribute}, **args)
         if fr != None:
@@ -856,11 +904,13 @@ class animate(SVGelement):
         if dur != None:
             self.attributes['dur'] = dur
 
+
 class animateMotion(SVGelement):
     """an=animateMotion(pathdata,dur,**args)
 
     animates a SVGelement over the given path in dur seconds
     """
+
     def __init__(self, pathdata, dur, **args):
         SVGelement.__init__(self, 'animateMotion', **args)
         if pathdata != None:
@@ -868,11 +918,13 @@ class animateMotion(SVGelement):
         if dur != None:
             self.attributes['dur'] = dur
 
+
 class animateTransform(SVGelement):
     """antr=animateTransform(type,from,to,dur,**args)
 
     transform an element from and to a value.
     """
+
     def __init__(self, type=None, fr=None, to=None, dur=None,**args):
         SVGelement.__init__(self, 'animateTransform', {'attributeName': 'transform'}, **args)
         # As far as I know the attributeName is always transform
@@ -884,11 +936,14 @@ class animateTransform(SVGelement):
             self.attributes['to'] = to
         if dur != None:
             self.attributes['dur'] = dur
+
+
 class animateColor(SVGelement):
     """ac=animateColor(attribute,type,from,to,dur,**args)
 
     Animates the color of a element
     """
+
     def __init__(self, attribute, type=None, fr=None, to=None,dur=None,**args):
         SVGelement.__init__(self, 'animateColor', {'attributeName': attribute}, **args)
         if type != None:
@@ -899,11 +954,14 @@ class animateColor(SVGelement):
             self.attributes['to'] = to
         if dur != None:
             self.attributes['dur'] = dur
+
+
 class set(SVGelement):
     """st=set(attribute,to,during,**args)
 
     sets an attribute to a value for a
     """
+
     def __init__(self, attribute, to=None, dur=None, **args):
         SVGelement.__init__(self, 'set', {'attributeName': attribute}, **args)
         if to != None:
@@ -912,7 +970,6 @@ class set(SVGelement):
             self.attributes['dur'] = dur
 
 
-
 class svg(SVGelement):
     """s=svg(viewbox,width,height,**args)
 
@@ -928,6 +985,7 @@ class svg(SVGelement):
     d.setSVG(s)
     d.toXml()
     """
+
     def __init__(self, viewBox=None, width=None, height=None, **args):
         SVGelement.__init__(self, 'svg', **args)
         if viewBox != None:
@@ -938,6 +996,7 @@ class svg(SVGelement):
             self.attributes['height'] = height
         self.namespace = "http://www.w3.org/2000/svg"
 
+
 class drawing:
     """d=drawing()
 
@@ -952,6 +1011,7 @@ class drawing:
     def __init__(self, entity={}):
         self.svg = None
         self.entity = entity
+
     def setSVG(self, svg):
         self.svg = svg
         # Voeg een element toe aan de grafiek toe.
@@ -1005,6 +1065,7 @@ class drawing:
             root = implementation.createDocument(None, None, doctype)
             # Create the xml document.
             global appender
+
             def appender(element, elementroot):
                 """This recursive function appends elements to an element and sets the attributes
                 and type. It stops when alle elements have been appended"""
@@ -1053,6 +1114,7 @@ class drawing:
                         f.close()
                 except:
                     print(("Cannot write SVG file: " + filename))
+
     def validate(self):
         try:
             import xml.parsers.xmlproc.xmlval
@@ -1066,9 +1128,10 @@ class drawing:
             raise Exception("SVG is not well formed, see messages above")
         else:
             print("SVG well formed")
-if __name__ == '__main__':
 
 
+if __name__ == '__main__':
+
     d = drawing()
     s = svg((0, 0, 100, 100))
     r = rect(-100, -100, 300, 300, 'cyan')