From 6b2cf51ed7ee3cd4e51f18d7581c770801996351 Mon Sep 17 00:00:00 2001 From: apurvabanka Date: Wed, 13 Nov 2024 02:49:24 -0500 Subject: [PATCH] requested changes --- fastkml/kml.py | 7 +++---- tests/kml_test.py | 4 ++-- tests/ogc_conformance/data/kml/output.kmz | Bin 120 -> 273 bytes 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fastkml/kml.py b/fastkml/kml.py index 4ade8ce2..b3db3621 100644 --- a/fastkml/kml.py +++ b/fastkml/kml.py @@ -27,7 +27,6 @@ """ import logging -import os from pathlib import Path from typing import IO from typing import Any @@ -257,7 +256,7 @@ def write( Write KML to a file Args: ---- - file_name: The file name where to save the file. + file_path: The file name where to save the file. Can be any string value prettyprint : bool, default=True Whether to pretty print the XML. @@ -288,9 +287,9 @@ def write( if file_path.suffix == ".kmz": with zipfile.ZipFile(file_path, 'w', zipfile.ZIP_DEFLATED) as kmz: - kmz.write(file_path, arcname=os.path.basename(file_path)) + kmz.writestr('doc.kml', tree) else: - with open(file_path, "w") as file: + with open(file_path, "w", encoding="UTF-8") as file: file.write(tree) diff --git a/tests/kml_test.py b/tests/kml_test.py index e5daeea7..f449a360 100644 --- a/tests/kml_test.py +++ b/tests/kml_test.py @@ -209,7 +209,7 @@ def test_write_kml_file(self) -> None: ) file_path = KMLFILEDIR / "output.kml" - kml.KML.write(doc, file_path=file_path, prettyprint=True, xml_declaration=True) + doc.write(file_path=file_path, prettyprint=True, xml_declaration=True) assert file_path.is_file(), "KML file was not created." @@ -236,7 +236,7 @@ def test_write_kmz_file(self) -> None: file_path = KMLFILEDIR / "output.kmz" - kml.KML.write(doc, file_path=file_path, prettyprint=True, xml_declaration=True) + doc.write(file_path=file_path, prettyprint=True, xml_declaration=True) assert file_path.is_file(), "KMZ file was not created." diff --git a/tests/ogc_conformance/data/kml/output.kmz b/tests/ogc_conformance/data/kml/output.kmz index a71b613ed95716eba56991a5222206cacd64ba70..bc737f2d7353ab51602cd510b5a879b62ffd1180 100644 GIT binary patch literal 273 zcmWIWW@Zs#U|`^2kQB>}RBcVVun@?*0mSS;oRXicmz|qq+q;pk$v~o|eEy=umoD5s zZ5K94q_dZ@|60xaHvW>>$B%0}_@>`^y8E>0+tX5?Smd`jJ9>u&Fj-hE{iyfiY0a7M zTc++#+p^40X=U%j$1dMG3RhXiPix)D`C%QibBB##+(xa*ub(|=yUFCXXzGb6(w`P- zn77Pjt!x!2wV!=c$Y4Q!Lzl#LYxz=-W6i0&|F>Vid$NT2#<~8M)B3;X<`{bJV+`