Skip to content

Commit

Permalink
Merge pull request #385 from cleder/develop
Browse files Browse the repository at this point in the history
1.0.0 release candidate 1
  • Loading branch information
cleder authored Nov 13, 2024
2 parents 977c38a + 0a21182 commit bbd4de6
Show file tree
Hide file tree
Showing 24 changed files with 220 additions and 357 deletions.
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ Geometries are handled as pygeoif_ objects.

Fastkml is continually tested

|test| |cov| |black| |mypy| |commit|
|test| |hypothesis| |cov| |black| |mypy| |commit|

.. |test| image:: https://github.com/cleder/fastkml/actions/workflows/run-all-tests.yml/badge.svg?branch=main
:target: https://github.com/cleder/fastkml/actions/workflows/run-all-tests.yml
:alt: Test

.. |hypothesis| image:: https://img.shields.io/badge/hypothesis-tested-brightgreen.svg
:alt: Tested with Hypothesis
:target: https://hypothesis.readthedocs.io

.. |cov| image:: https://codecov.io/gh/cleder/fastkml/branch/main/graph/badge.svg?token=VIuhPHq0ow
:target: http://codecov.io/github/cleder/fastkml?branch=main
:alt: codecov.io
Expand Down
2 changes: 1 addition & 1 deletion fastkml/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
The only purpose of this module is to provide a version number for the package.
"""

__version__ = "1.0.0b3"
__version__ = "1.0.0rc1"

__all__ = ["__version__"]
36 changes: 2 additions & 34 deletions fastkml/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
from fastkml.views import LookAt
from fastkml.views import Region

__all__ = ["KmlGeometry", "NetworkLink", "Placemark", "Snippet"]

logger = logging.getLogger(__name__)

KmlGeometry = Union[
Expand Down Expand Up @@ -303,40 +305,6 @@ def __init__(
self.extended_data = extended_data
self.times = times

def __repr__(self) -> str:
"""
Return a string representation of the _Feature object.
Returns
-------
str: String representation of the _Feature object.
"""
return (
f"{self.__class__.__module__}.{self.__class__.__name__}("
f"ns={self.ns!r}, "
f"name_spaces={self.name_spaces!r}, "
f"id={self.id!r}, "
f"target_id={self.target_id!r}, "
f"name={self.name!r}, "
f"visibility={self.visibility!r}, "
f"isopen={self.isopen!r}, "
f"atom_link={self.atom_link!r}, "
f"atom_author={self.atom_author!r}, "
f"address={self.address!r}, "
f"phone_number={self.phone_number!r}, "
f"snippet={self.snippet!r}, "
f"description={self.description!r}, "
f"view={self.view!r}, "
f"times={self.times!r}, "
f"style_url={self.style_url!r}, "
f"styles={self.styles!r}, "
f"region={self.region!r}, "
f"extended_data={self.extended_data!r}, "
f"**{self._get_splat()!r},"
")"
)


registry.register(
_Feature,
Expand Down
13 changes: 0 additions & 13 deletions fastkml/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,6 @@ def __init__(
)
self.altitude_mode = altitude_mode

def __repr__(self) -> str:
"""Create a string (c)representation for _Geometry."""
return (
f"{self.__class__.__module__}.{self.__class__.__name__}("
f"ns={self.ns!r}, "
f"name_spaces={self.name_spaces!r}, "
f"id={self.id!r}, "
f"target_id={self.target_id!r}, "
f"altitude_mode={self.altitude_mode}, "
f"**{self._get_splat()!r},"
")"
)


class Point(_Geometry):
"""
Expand Down
19 changes: 9 additions & 10 deletions fastkml/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,16 +1100,15 @@ def datetime_subelement_kwarg(
return {}
node_text = node.text.strip() if node.text else ""
if node_text:
try:
return {kwarg: cls.parse(node_text)} # type: ignore[attr-defined]
except ValueError as exc:
handle_error(
error=exc,
strict=strict,
element=element,
node=node,
expected="DateTime",
)
if kdt := cls.parse(node_text): # type: ignore[attr-defined]
return {kwarg: kdt}
handle_error(
error=ValueError(f"Invalid DateTime value: {node_text}"),
strict=strict,
element=element,
node=node,
expected="DateTime",
)
return {}


Expand Down
38 changes: 9 additions & 29 deletions fastkml/overlays.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
from fastkml.views import LookAt
from fastkml.views import Region

__all__ = [
"GroundOverlay",
"ImagePyramid",
"KmlGeometry",
"LatLonBox",
"PhotoOverlay",
"ViewVolume",
]

logger = logging.getLogger(__name__)

KmlGeometry = Union[
Expand Down Expand Up @@ -207,35 +216,6 @@ def __init__(
self.color = clean_string(color)
self.draw_order = draw_order

def __repr__(self) -> str:
"""Create a string (c)representation for _Overlay."""
return (
f"{self.__class__.__module__}.{self.__class__.__name__}("
f"ns={self.ns!r}, "
f"name_spaces={self.name_spaces!r}, "
f"id={self.id!r}, "
f"target_id={self.target_id!r}, "
f"name={self.name!r}, "
f"visibility={self.visibility!r}, "
f"isopen={self.isopen!r}, "
f"atom_link={self.atom_link!r}, "
f"atom_author={self.atom_author!r}, "
f"address={self.address!r}, "
f"phone_number={self.phone_number!r}, "
f"snippet={self.snippet!r}, "
f"description={self.description!r}, "
f"view={self.view!r}, "
f"times={self.times!r}, "
f"style_url={self.style_url!r}, "
f"styles={self.styles!r}, "
f"region={self.region!r}, "
f"extended_data={self.extended_data!r}, "
f"color={self.color!r}, "
f"draw_order={self.draw_order!r}, "
f"icon={self.icon!r}, "
")"
)


registry.register(
_Overlay,
Expand Down
14 changes: 0 additions & 14 deletions fastkml/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,6 @@ def __init__(
self.color = clean_string(color)
self.color_mode = color_mode

def __repr__(self) -> str:
"""Create a string (c)representation for _ColorStyle."""
return (
f"{self.__class__.__module__}.{self.__class__.__name__}("
f"ns={self.ns!r}, "
f"name_spaces={self.name_spaces!r}, "
f"id={self.id!r}, "
f"target_id={self.target_id!r}, "
f"color={self.color!r}, "
f"color_mode={self.color_mode}, "
f"**{self._get_splat()!r},"
")"
)


registry.register(
_ColorStyle,
Expand Down
37 changes: 7 additions & 30 deletions fastkml/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def has_attribute_values(obj: object, **kwargs: Any) -> bool:
return False


def find_in(
def find_all(
obj: object,
*,
of_type: Optional[Union[Type[object], Tuple[Type[object], ...]]] = None,
**kwargs: Any,
) -> Generator[object, None, None]:
"""
Find all instances of type in the attributes of an object.
Find all instances of a given type with attributes matching the kwargs.
Args:
----
Expand All @@ -50,6 +50,11 @@ def find_in(
An iterable of all instances of the given type in the given object.
"""
if (of_type is None or isinstance(obj, of_type)) and has_attribute_values(
obj,
**kwargs,
):
yield obj
try:
attrs = (attr for attr in obj.__dict__ if not attr.startswith("_"))
except AttributeError:
Expand All @@ -63,34 +68,6 @@ def find_in(
yield from find_all(attr, of_type=of_type, **kwargs)


def find_all(
obj: object,
*,
of_type: Optional[Union[Type[object], Tuple[Type[object], ...]]] = None,
**kwargs: Any,
) -> Generator[object, None, None]:
"""
Find all instances of a given type with attributes matching the kwargs.
Args:
----
obj: The object to search.
of_type: The type(s) to search for or None for any type.
**kwargs: Attributes of the object to match.
Returns:
-------
An iterable of all instances of the given type in the given object.
"""
if (of_type is None or isinstance(obj, of_type)) and has_attribute_values(
obj,
**kwargs,
):
yield obj
yield from find_in(obj, of_type=of_type, **kwargs)


def find(
obj: object,
*,
Expand Down
18 changes: 0 additions & 18 deletions fastkml/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,6 @@ def __init__(
self.tilt = tilt
self.altitude_mode = altitude_mode

def __repr__(self) -> str:
"""Create a string (c)representation for _AbstractView."""
return (
f"{self.__class__.__module__}.{self.__class__.__name__}("
f"ns={self.ns!r}, "
f"name_spaces={self.name_spaces!r}, "
f"id={self.id!r}, "
f"target_id={self.target_id!r}, "
f"longitude={self.longitude!r}, "
f"latitude={self.latitude!r}, "
f"altitude={self.altitude!r}, "
f"heading={self.heading!r}, "
f"tilt={self.tilt!r}, "
f"altitude_mode={self.altitude_mode}, "
f"**{self._get_splat()!r},"
")"
)


registry.register(
_AbstractView,
Expand Down
Loading

0 comments on commit bbd4de6

Please sign in to comment.