From 10ebe81d2cb1ff7a1142ae1aaefe801e8fe896a0 Mon Sep 17 00:00:00 2001 From: apurvabanka Date: Sun, 1 Dec 2024 17:35:14 -0500 Subject: [PATCH] requested changes --- fastkml/__init__.py | 4 ++-- fastkml/kml.py | 2 +- fastkml/network_link_control.py | 22 ++++++++++++---------- tests/network_link_control_test.py | 10 +++------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/fastkml/__init__.py b/fastkml/__init__.py index 0c9fb66f..e94dae15 100644 --- a/fastkml/__init__.py +++ b/fastkml/__init__.py @@ -31,7 +31,6 @@ from fastkml.atom import Link as AtomLink from fastkml.containers import Document from fastkml.containers import Folder -from fastkml.network_link_control import NetworkLinkControl from fastkml.data import Data from fastkml.data import ExtendedData from fastkml.data import Schema @@ -59,6 +58,7 @@ from fastkml.model import Orientation from fastkml.model import ResourceMap from fastkml.model import Scale +from fastkml.network_link_control import NetworkLinkControl from fastkml.overlays import GroundOverlay from fastkml.overlays import ImagePyramid from fastkml.overlays import LatLonBox @@ -91,7 +91,6 @@ __all__ = [ "KML", - "NetworkLinkControl", "Alias", "AtomAuthor", "AtomContributor", @@ -121,6 +120,7 @@ "Model", "MultiGeometry", "NetworkLink", + "NetworkLinkControl", "Orientation", "OuterBoundaryIs", "OverlayXY", diff --git a/fastkml/kml.py b/fastkml/kml.py index b858e40f..70d1b8ec 100644 --- a/fastkml/kml.py +++ b/fastkml/kml.py @@ -66,7 +66,7 @@ Placemark, GroundOverlay, PhotoOverlay, - NetworkLinkControl + NetworkLinkControl, ] diff --git a/fastkml/network_link_control.py b/fastkml/network_link_control.py index 1e9d05bd..feeec67d 100644 --- a/fastkml/network_link_control.py +++ b/fastkml/network_link_control.py @@ -14,26 +14,26 @@ # along with this library; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA import logging - from typing import Any from typing import Dict from typing import Optional from typing import Union + from fastkml import config from fastkml.base import _XMLObject from fastkml.helpers import datetime_subelement +from fastkml.helpers import datetime_subelement_kwarg from fastkml.helpers import float_subelement from fastkml.helpers import subelement_float_kwarg -from fastkml.helpers import datetime_subelement_kwarg from fastkml.helpers import subelement_text_kwarg from fastkml.helpers import text_subelement -from fastkml.helpers import xml_subelement_list -from fastkml.helpers import xml_subelement_list_kwarg +from fastkml.helpers import xml_subelement +from fastkml.helpers import xml_subelement_kwarg from fastkml.registry import RegistryItem from fastkml.registry import registry from fastkml.times import KmlDateTime -from fastkml.views import Camera, LookAt - +from fastkml.views import Camera +from fastkml.views import LookAt __all__ = [ "NetworkLinkControl", @@ -69,7 +69,7 @@ def __init__( link_snippet: Optional[str] = None, expires: Optional[KmlDateTime] = None, view: Optional[Union[Camera, LookAt]] = None, - **kwargs: Any + **kwargs: Any, ) -> None: super().__init__( ns=ns, @@ -83,7 +83,7 @@ def __init__( link_snippet=link_snippet, expires=expires, view=view, - **kwargs + **kwargs, ) def __repr__(self) -> str: @@ -122,6 +122,7 @@ def __repr__(self) -> str: classes=(float,), get_kwarg=subelement_float_kwarg, set_element=float_subelement, + default=0, ), ) registry.register( @@ -133,6 +134,7 @@ def __repr__(self) -> str: classes=(float,), get_kwarg=subelement_float_kwarg, set_element=float_subelement, + default=-1, ), ) registry.register( @@ -211,7 +213,7 @@ def __repr__(self) -> str: Camera, LookAt, ), - get_kwarg=xml_subelement_list_kwarg, - set_element=xml_subelement_list, + get_kwarg=xml_subelement_kwarg, + set_element=xml_subelement, ), ) diff --git a/tests/network_link_control_test.py b/tests/network_link_control_test.py index 5fc9720e..b348ee52 100644 --- a/tests/network_link_control_test.py +++ b/tests/network_link_control_test.py @@ -51,9 +51,8 @@ def test_network_link_control_obj(self) -> None: assert network_control_obj.link_name == "link_name" assert network_control_obj.link_description == "link_description" assert network_control_obj.link_snippet == "link_snippet" - assert network_control_obj.expires == kml_datetime - - assert network_control_obj.view == view + assert str(network_control_obj.expires) == str(kml_datetime) + assert str(network_control_obj.view) == str(view) def test_network_link_control_kml(self) -> None: doc = ( @@ -77,7 +76,4 @@ def test_network_link_control_kml(self) -> None: expires=kml_datetime, ) - assert nc.min_refresh_period == nc_obj.min_refresh_period - assert nc.max_session_length == nc_obj.max_session_length - assert nc.link_snippet == nc_obj.link_snippet - assert nc.expires == nc_obj.expires + assert nc == nc_obj