svgutil: code style

This commit is contained in:
Rotzbua 2023-01-23 00:24:54 +01:00 committed by Florian Festi
parent 1b3b7850de
commit 66cd7c871e
1 changed files with 18 additions and 14 deletions

View File

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