Skip to content

Commit

Permalink
doc string
Browse files Browse the repository at this point in the history
  • Loading branch information
apurvabanka committed Nov 7, 2024
1 parent 8524025 commit c33c875
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions fastkml/kml.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,22 @@ def parse(
name_spaces: Optional[Dict[str, str]] = None,
strict: bool = True,
) -> Self:
"""
Parse a KML file and return a KML object.
Args:
----
file: The file to parse.
Can be a file path (str or Path), or a file-like object.
Keyword Args:
------------
ns (Optional[str]): The namespace of the KML file.
If not provided, it will be inferred from the root element.
name_spaces (Optional[Dict[str, str]]): Additional namespaces.
strict (bool): Whether to enforce strict parsing rules. Defaults to True.
Returns:
-------
KML object: The parsed KML object.
"""
try:
tree = config.etree.parse(
file,
Expand Down Expand Up @@ -193,10 +209,21 @@ def write(
self,
file_name:pathlib.Path,
*,
prettyprint:bool=False,
xml_declaration:bool=False
prettyprint:bool=True,
xml_declaration:bool=True
) -> None:
"""
Write KML to a file
Args:
----
file_name: The file name where to save the file.
Can be any string value
prettyprint : bool, default=True
Whether to pretty print the XML.
xml_declarationL bool, default=True
For True, value is '<?xml version="1.0" encoding="UTF-8"?>' else ''
"""
element = self.etree_element()

tree = config.etree.tostring(
Expand Down

0 comments on commit c33c875

Please sign in to comment.