Skip to content

Commit

Permalink
better docstrings and ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Jul 18, 2024
1 parent 4541ea0 commit d592b0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion fastkml/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU Lesser General Public License
# 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 @@ -107,6 +107,15 @@ def __repr__(self) -> str:
)

def __bool__(self) -> bool:
"""
Check if the link has a valid href.
Returns
-------
bool
True if the link has a valid href, False otherwise.
"""
return bool(self.href)


Expand Down
6 changes: 5 additions & 1 deletion fastkml/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@


class TimeMixin:
"""Mixin for classes that have a time element."""

times: Optional[Union[TimeSpan, TimeStamp]] = None

@property
def time_stamp(self) -> Optional[KmlDateTime]:
"""This just returns the datetime portion of the timestamp."""
"""Return the timestamp."""
return self.times.timestamp if isinstance(self.times, TimeStamp) else None

@property
def begin(self) -> Optional[KmlDateTime]:
"""Return the start time of a time span."""
return self.times.begin if isinstance(self.times, TimeSpan) else None

@property
def end(self) -> Optional[KmlDateTime]:
"""Return the end time of a time span."""
return self.times.end if isinstance(self.times, TimeSpan) else None

0 comments on commit d592b0d

Please sign in to comment.