Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski authored Nov 15, 2024
1 parent c79ec11 commit d4488ba
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions upcean/svgcreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,21 @@ def saveas(self, filename, pretty=False, indent=2, encoding='utf-8'):
self.filename = filename
self.save(pretty=pretty, indent=indent, encoding=encoding)

def write(self, fileobj, pretty=False, indent=2, encoding='utf-8'):
"""
Write XML string to a file-like object.
Parameters:
- fileobj: a file-like object with a write method.
- pretty: True for pretty-printed output.
- indent: indentation level for pretty-printed output.
- encoding: character encoding for the output.
"""
svg_string = self.tostring(pretty=pretty, indent=indent)
if isinstance(svg_string, str):
svg_string = svg_string.encode(encoding)
fileobj.write(svg_string)

# Factory methods to create SVG elements
def line(self, start, end, **kwargs):
return Line(start, end, **kwargs)
Expand Down

0 comments on commit d4488ba

Please sign in to comment.