svgutil: code style
This commit is contained in:
parent
1b3b7850de
commit
66cd7c871e
|
@ -17,6 +17,7 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
|
|
||||||
ElementTree.register_namespace("", "http://www.w3.org/2000/svg")
|
ElementTree.register_namespace("", "http://www.w3.org/2000/svg")
|
||||||
ElementTree.register_namespace("xlink", "http://www.w3.org/1999/xlink")
|
ElementTree.register_namespace("xlink", "http://www.w3.org/1999/xlink")
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ unit2mm = {"mm" : 1.0,
|
||||||
"pc": 90.0 / 25.4 / 15,
|
"pc": 90.0 / 25.4 / 15,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def getSizeInMM(tree):
|
def getSizeInMM(tree):
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
m = re.match(r"(-?\d+\.?\d*)(\D+)", root.get("height"))
|
m = re.match(r"(-?\d+\.?\d*)(\D+)", root.get("height"))
|
||||||
|
@ -40,6 +42,7 @@ def getSizeInMM(tree):
|
||||||
|
|
||||||
return width, height
|
return width, height
|
||||||
|
|
||||||
|
|
||||||
def getViewBox(tree):
|
def getViewBox(tree):
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
m = re.match(r"\s*(-?\d+\.?\d*)\s+"
|
m = re.match(r"\s*(-?\d+\.?\d*)\s+"
|
||||||
|
@ -49,14 +52,15 @@ def getViewBox(tree):
|
||||||
|
|
||||||
return [float(m) for m in m.groups()]
|
return [float(m) for m in m.groups()]
|
||||||
|
|
||||||
|
|
||||||
def ticksPerMM(tree):
|
def ticksPerMM(tree):
|
||||||
width, height = getSizeInMM(tree)
|
width, height = getSizeInMM(tree)
|
||||||
x1, y1, x2, y2 = getViewBox(tree)
|
x1, y1, x2, y2 = getViewBox(tree)
|
||||||
|
|
||||||
return x2 / width, y2 / height
|
return x2 / width, y2 / height
|
||||||
|
|
||||||
def svgMerge(box, inkscape, output):
|
|
||||||
|
|
||||||
|
def svgMerge(box, inkscape, output):
|
||||||
src_tree = ElementTree.parse(box)
|
src_tree = ElementTree.parse(box)
|
||||||
dest_tree = ElementTree.parse(inkscape)
|
dest_tree = ElementTree.parse(inkscape)
|
||||||
dest_root = dest_tree.getroot()
|
dest_root = dest_tree.getroot()
|
||||||
|
|
Loading…
Reference in New Issue