From ab44fcd5640f43be9089516e4252af577a0698f6 Mon Sep 17 00:00:00 2001 From: Andy Port Date: Tue, 23 Jun 2020 22:42:23 -0700 Subject: [PATCH] save and write fixed, __repr__() and pretty() methods added --- svgpathtools/document.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/svgpathtools/document.py b/svgpathtools/document.py index 96406ca..f88f5ba 100644 --- a/svgpathtools/document.py +++ b/svgpathtools/document.py @@ -253,7 +253,11 @@ class Document: def paths(self, group_filter=lambda x: True, path_filter=lambda x: True, path_conversions=CONVERSIONS): - """Returns a list of all paths in the document.""" + """Returns a list of all paths in the document. + + Note that any transform attributes are applied before returning + the paths. + """ return flattened_paths(self.tree.getroot(), group_filter, path_filter, path_conversions) @@ -418,7 +422,7 @@ class Document: return parseString(repr(self)).toprettyxml(**kwargs) def save(self, filepath, prettify=False, **kwargs): - with open(filepath, 'w') as output_svg: + with open(filepath, 'w+') as output_svg: if prettify: output_svg.write(self.pretty(**kwargs)) else: @@ -438,6 +442,6 @@ class Document: # write to a (by default temporary) file with open(filepath, 'w') as output_svg: - output_svg.write(self.as_string()) + output_svg.write(repr(self)) open_in_browser(filepath)