Skip to content

Commit

Permalink
docs: annotate .save()
Browse files Browse the repository at this point in the history
  • Loading branch information
rien333 committed Dec 16, 2024
1 parent 3fec5cf commit d09641a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mdto/mdto.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@ def save(
"encoding": "UTF-8",
},
) -> None:
"""Save object to an XML file.
"""Save object to an XML file, provided it satifies the MDTO schema
Args:
file_or_filename (str | TextIO): Path or file-object to write the object's XML representation to
file_or_filename (str | TextIO): Path or file-like object to write object's XML representation to
lxml_args (Optional[dict]): Extra keyword arguments to pass to lxml's write() method.
Defaults to `{xml_declaration=True, pretty_print=True, encoding="UTF-8"}`.
Expand All @@ -467,10 +467,10 @@ def save(
https://lxml.de/apidoc/lxml.etree.html#lxml.etree._ElementTree.write
Raises:
ValidationError: object is invalid MDTO
ValidationError: Raised when the object voilates the MDTO schema
"""
# lxml wants files in binary mode, so pass along a file's raw byte stream
if hasattr(file_or_filename, "write"):
# "re-open" file in binary mode
file_or_filename = file_or_filename.buffer.raw

# validate before serialization to ensure correctness
Expand Down

0 comments on commit d09641a

Please sign in to comment.