Skip to content

Commit

Permalink
CR modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Nov 9, 2024
1 parent 817b3bb commit e0e7210
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion fastkml/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# along with this library; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""Link and Icon elements."""

from typing import Any
from typing import Dict
from typing import Optional
Expand Down Expand Up @@ -77,7 +78,7 @@ def __init__(
target_id=target_id,
**kwargs,
)
self.href = href or ""
self.href = href.strip() if href else ""
self.refresh_mode = refresh_mode
self.refresh_interval = refresh_interval
self.view_refresh_mode = view_refresh_mode
Expand Down
18 changes: 16 additions & 2 deletions fastkml/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class IconStyle(_ColorStyle):
heading: Optional[float]
# Direction (that is, North, South, East, West), in degrees.
# Default=0 (North).
icon_href: Optional[str]
icon: Optional[Icon]
# An HTTP address or a local file specification used to load an icon.
hot_spot: Optional[HotSpot]

Expand All @@ -437,6 +437,7 @@ def __init__(
scale: Optional[float] = None,
heading: Optional[float] = None,
icon: Optional[Icon] = None,
icon_href: Optional[str] = None,
hot_spot: Optional[HotSpot] = None,
**kwargs: Any,
) -> None:
Expand All @@ -455,6 +456,7 @@ def __init__(
scale (Optional[float]): The scale of the Style object.
heading (Optional[float]): The heading of the Style object.
icon (Optional[Icon]): The icon of the Style object.
icon_href (Optional[str]): The href of the icon can be passed as a shortcut.
hot_spot (Optional[HotSpot]): The hot spot of the Style object.
**kwargs (Any): Additional keyword arguments.
Expand All @@ -472,9 +474,16 @@ def __init__(
color_mode=color_mode,
**kwargs,
)

icon_href = icon_href.strip() or None if icon_href else None
self.scale = scale
self.heading = heading
if icon_href and icon:
logger.warning(

Check warning on line 481 in fastkml/styles.py

View check run for this annotation

Codecov / codecov/patch

fastkml/styles.py#L481

Added line #L481 was not covered by tests
"Both icon_href and icon were provided. "
"Ignoring icon_href and using icon.",
)
if icon_href and not icon:
icon = Icon(ns=ns, name_spaces=name_spaces, href=icon_href)

Check warning on line 486 in fastkml/styles.py

View check run for this annotation

Codecov / codecov/patch

fastkml/styles.py#L486

Added line #L486 was not covered by tests
self.icon = icon
self.hot_spot = hot_spot

Expand Down Expand Up @@ -508,6 +517,11 @@ def __bool__(self) -> bool:
"""
return bool(self.icon)

@property
def icon_href(self) -> Optional[str]:
"""Return the icon href."""
return self.icon.href if self.icon else None

Check warning on line 523 in fastkml/styles.py

View check run for this annotation

Codecov / codecov/patch

fastkml/styles.py#L523

Added line #L523 was not covered by tests


registry.register(
IconStyle,
Expand Down
2 changes: 1 addition & 1 deletion tests/hypothesis/style_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_fuzz_icon_style(
color_mode: typing.Optional[fastkml.enums.ColorMode],
scale: typing.Optional[float],
heading: typing.Optional[float],
icon: typing.Optional[fastkml.Icon],
icon: typing.Optional[fastkml.links.Icon],
hot_spot: typing.Optional[fastkml.styles.HotSpot],
) -> None:
icon_style = fastkml.IconStyle(
Expand Down

0 comments on commit e0e7210

Please sign in to comment.