From: Antonio Ospite Date: Tue, 26 Jun 2018 14:18:31 +0000 (+0200) Subject: svgwrite_diagram: add a test function X-Git-Url: https://git.ao2.it/flexagon-toolkit.git/commitdiff_plain/de12520337565607ec65190f8c83ba8aa8edfef6?ds=inline;hp=1cd1b488690ff3007df258adbfb198f5bdedfb80 svgwrite_diagram: add a test function Add a test function similar to the one used in the cairo backend. Add also the same workaround to handle local includes in python2. --- diff --git a/src/diagram/svgwrite_diagram.py b/src/diagram/svgwrite_diagram.py index 186d134..bbc88eb 100755 --- a/src/diagram/svgwrite_diagram.py +++ b/src/diagram/svgwrite_diagram.py @@ -21,7 +21,10 @@ import warnings from math import degrees import svgwrite from svgwrite.data.types import SVGAttribute -from .diagram import Diagram +try: + from .diagram import Diagram +except ValueError: + from diagram import Diagram class InkscapeDrawing(svgwrite.Drawing): @@ -189,3 +192,15 @@ class SvgwriteDiagram(Diagram): # XXX: this is just a very quick and dirty estimate to advance the text return self.font_size * len(text) / 2 + + +def test(): + diagram = SvgwriteDiagram(400, 400) + + Diagram.test(diagram) + + diagram.save_svg('svgwrite_diagram_test.svg') + + +if __name__ == "__main__": + test()