save() now requires filename
parent
0955278f73
commit
4bc146fd62
|
@ -210,8 +210,7 @@ class Document:
|
||||||
|
|
||||||
self.root = self.tree.getroot()
|
self.root = self.tree.getroot()
|
||||||
|
|
||||||
def flatten_all_paths(self,
|
def flatten_all_paths(self, group_filter=lambda x: True,
|
||||||
group_filter=lambda x: True,
|
|
||||||
path_filter=lambda x: True,
|
path_filter=lambda x: True,
|
||||||
path_conversions=CONVERSIONS):
|
path_conversions=CONVERSIONS):
|
||||||
"""Forward the tree of this document into the more general
|
"""Forward the tree of this document into the more general
|
||||||
|
@ -219,12 +218,8 @@ class Document:
|
||||||
return flatten_all_paths(self.tree.getroot(), group_filter,
|
return flatten_all_paths(self.tree.getroot(), group_filter,
|
||||||
path_filter, path_conversions)
|
path_filter, path_conversions)
|
||||||
|
|
||||||
def flatten_group(self,
|
def flatten_group(self, group, recursive=True, group_filter=lambda x: True,
|
||||||
group,
|
path_filter=lambda x: True, path_conversions=CONVERSIONS):
|
||||||
recursive=True,
|
|
||||||
group_filter=lambda x: True,
|
|
||||||
path_filter=lambda x: True,
|
|
||||||
path_conversions=CONVERSIONS):
|
|
||||||
if all(isinstance(s, str) for s in group):
|
if all(isinstance(s, str) for s in group):
|
||||||
# If we're given a list of strings, assume it represents a
|
# If we're given a list of strings, assume it represents a
|
||||||
# nested sequence
|
# nested sequence
|
||||||
|
@ -342,10 +337,7 @@ class Document:
|
||||||
return SubElement(parent, '{{{0}}}g'.format(
|
return SubElement(parent, '{{{0}}}g'.format(
|
||||||
SVG_NAMESPACE['svg']), group_attribs)
|
SVG_NAMESPACE['svg']), group_attribs)
|
||||||
|
|
||||||
def save(self, filename=None):
|
def save(self, filename):
|
||||||
if filename is None:
|
|
||||||
filename = self.original_filename
|
|
||||||
|
|
||||||
with open(filename, 'w') as output_svg:
|
with open(filename, 'w') as output_svg:
|
||||||
output_svg.write(etree.tostring(self.tree.getroot()))
|
output_svg.write(etree.tostring(self.tree.getroot()))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue