From c85481b945d42154ede4dcfd4bec4372b15620aa Mon Sep 17 00:00:00 2001 From: Anders Hoff Date: Sun, 4 Mar 2018 21:13:07 +0100 Subject: [PATCH] use pretty printing in svgwrite. --- build/lib/svgpathtools/paths2svg.py | 10 ++-------- svgpathtools/paths2svg.py | 8 +------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/build/lib/svgpathtools/paths2svg.py b/build/lib/svgpathtools/paths2svg.py index 4854d4e..b84085a 100644 --- a/build/lib/svgpathtools/paths2svg.py +++ b/build/lib/svgpathtools/paths2svg.py @@ -5,7 +5,6 @@ segments.""" from __future__ import division, absolute_import, print_function from math import ceil from os import getcwd, path as os_path, makedirs -from xml.dom.minidom import parse as md_xml_parse from svgwrite import Drawing, text as txt from time import time from warnings import warn @@ -153,7 +152,7 @@ def disvg(paths=None, colors=None, :param svg_attributes - a dictionary of attributes for output svg. Note 1: This will override any other conflicting settings. - Note 2: Setting `svg_attributes={'debug': False}` may result in a + Note 2: Setting `svg_attributes={'debug': False}` may result in a significant increase in speed. NOTES: @@ -353,12 +352,7 @@ def disvg(paths=None, colors=None, # save svg if not os_path.exists(os_path.dirname(filename)): makedirs(os_path.dirname(filename)) - dwg.save() - - # re-open the svg, make the xml pretty, and save it again - xmlstring = md_xml_parse(filename).toprettyxml() - with open(filename, 'w') as f: - f.write(xmlstring) + dwg.save(pretty=True) # try to open in web browser if openinbrowser: diff --git a/svgpathtools/paths2svg.py b/svgpathtools/paths2svg.py index 4443a2e..a8422c1 100644 --- a/svgpathtools/paths2svg.py +++ b/svgpathtools/paths2svg.py @@ -5,7 +5,6 @@ segments.""" from __future__ import division, absolute_import, print_function from math import ceil from os import getcwd, path as os_path, makedirs -from xml.dom.minidom import parse as md_xml_parse from svgwrite import Drawing, text as txt from time import time from warnings import warn @@ -366,12 +365,7 @@ def disvg(paths=None, colors=None, # save svg if not os_path.exists(os_path.dirname(filename)): makedirs(os_path.dirname(filename)) - dwg.save() - - # re-open the svg, make the xml pretty, and save it again - xmlstring = md_xml_parse(filename).toprettyxml() - with open(filename, 'w') as f: - f.write(xmlstring) + dwg.save(pretty=True) # try to open in web browser if openinbrowser: