Commit c82da85e authored by Gary Hodgson's avatar Gary Hodgson Committed by Guillaume Seguin

formatting of code

parent a5281465
......@@ -52,14 +52,14 @@ def main():
"""Entry-point of the executable."""
# Get command-line options
option_parser = optparse.OptionParser(
usage="usage: %prog filename [options]", version=VERSION)
usage = "usage: %prog filename [options]", version = VERSION)
option_parser.add_option(
"-f", "--format", help="output format")
"-f", "--format", help = "output format")
option_parser.add_option(
"-d", "--dpi", help="svg resolution", default=96)
"-d", "--dpi", help = "svg resolution", default = 96)
option_parser.add_option(
"-o", "--output",
default="", help="output filename")
default = "", help = "output filename")
options, args = option_parser.parse_args()
# Print help if no argument is given
......
......@@ -79,7 +79,7 @@ def remove_svg_namespace(tree):
class Node(dict):
"""SVG node with dict-like properties and children."""
def __init__(self, node, parent=None):
def __init__(self, node, parent = None):
"""Create the Node from ElementTree ``node``, with ``parent`` Node."""
super(Node, self).__init__()
self.children = ()
......@@ -145,11 +145,11 @@ class Node(dict):
children = []
for child in node:
children.append(Node(child, parent=self))
children.append(Node(child, parent = self))
if child.tail:
anonymous = ElementTree.Element('tspan')
anonymous.text = child.tail
children.append(Node(anonymous, parent=self))
children.append(Node(anonymous, parent = self))
return list(children)
......
......@@ -50,7 +50,7 @@ class Surface(object):
surface_class = None
@classmethod
def convert(cls, bytestring=None, **kwargs):
def convert(cls, bytestring = None, **kwargs):
"""Convert a SVG document to the format for this class.
Specify the input by passing one of these:
......@@ -172,7 +172,7 @@ class Surface(object):
"""Draw the root ``node``."""
self.draw(node)
def draw(self, node, stroke_and_fill=True):
def draw(self, node, stroke_and_fill = True):
"""Draw ``node`` and its children."""
old_font_size = self.font_size
self.font_size = size(self, node.get("font-size", "12pt"))
......
......@@ -200,7 +200,7 @@ COLORS = {
"windowtext": "#000000"}
def color(string=None, opacity=1):
def color(string = None, opacity = 1):
"""Replace ``string`` representing a color by a RGBA tuple."""
if not string or string in ("none", "transparent"):
return (0, 0, 0, 0)
......
......@@ -107,7 +107,7 @@ def draw_gradient(surface, node, name):
if gradient_node.get("gradientUnits") != "userSpaceOnUse":
gradient_pattern.set_matrix(cairo.Matrix(
1 / width, 0, 0, 1 / height, - x / width, - y / height))
1 / width, 0, 0, 1 / height, -x / width, -y / height))
gradient_pattern.set_extend(getattr(
cairo, "EXTEND_%s" % node.get("spreadMethod", "pad").upper()))
......@@ -141,7 +141,7 @@ def draw_pattern(surface, name):
surface.context.set_source(pattern_pattern)
def draw_marker(surface, node, position="mid"):
def draw_marker(surface, node, position = "mid"):
"""Draw a marker."""
# TODO: manage markers for other tags than path
if position == "start":
......@@ -229,7 +229,7 @@ def use(surface, node):
del node["viewBox"]
href = node.get("{http://www.w3.org/1999/xlink}href")
url = list(urls(href))[0]
tree = Tree(url=url, parent=node)
tree = Tree(url = url, parent = node)
surface.set_context_size(*node_format(surface, tree))
surface.draw(tree)
surface.context.restore()
......
......@@ -68,7 +68,7 @@ def node_format(surface, node):
return width, height, viewbox
def normalize(string=None):
def normalize(string = None):
"""Normalize a string corresponding to an array of various values."""
string = string.replace("-", " -")
string = string.replace(",", " ")
......@@ -91,7 +91,7 @@ def normalize(string=None):
return string.strip()
def point(surface, string=None):
def point(surface, string = None):
"""Return ``(x, y, trailing_text)`` from ``string``."""
if not string:
return (0, 0, "")
......
......@@ -56,7 +56,7 @@ def open_data_url(url):
if header:
semi = header.rfind(";")
if semi >= 0 and "=" not in header[semi:]:
encoding = header[semi+1:]
encoding = header[semi + 1:]
else:
encoding = ""
else:
......@@ -110,7 +110,7 @@ def image(surface, node):
del node["y"]
if "viewBox" in node:
del node["viewBox"]
tree = Tree(bytestring=image_bytes)
tree = Tree(bytestring = image_bytes)
tree_width, tree_height, viewbox = node_format(surface, tree)
if not tree_width or not tree_height:
tree_width = tree["width"] = width
......
......@@ -30,7 +30,7 @@ UNITS = {
"px": None}
def size(surface, string, reference="xy"):
def size(surface, string, reference = "xy"):
"""Replace a ``string`` with units by a float value.
If ``reference`` is a float, it is used as reference for percentages. If it
......
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