From f08114a14ac344f577909c3239b8c18962d18760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 23 Jul 2024 18:55:25 +0200 Subject: [PATCH] chg: Avoid if not when possible --- pylookyloo/api.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pylookyloo/api.py b/pylookyloo/api.py index 49a5378..4a62fe8 100644 --- a/pylookyloo/api.py +++ b/pylookyloo/api.py @@ -498,14 +498,14 @@ def send_mail(self, tree_uuid: str, email: str = '', comment: str | None = None) def get_recent_captures(self, timestamp: str | datetime | float | None=None) -> list[str]: '''Gets the uuids of the most recent captures - :param timestamp: Timestamp of the capture + :param timestamp: Oldest timestamp to consider ''' - if not timestamp: - url = urljoin(self.root_url, str(PurePosixPath('json', 'recent_captures'))) - else: + if timestamp: if isinstance(timestamp, datetime): timestamp = timestamp.timestamp() url = urljoin(self.root_url, str(PurePosixPath('json', 'recent_captures', str(timestamp)))) + else: + url = urljoin(self.root_url, str(PurePosixPath('json', 'recent_captures'))) r = self.session.get(url) return r.json() @@ -514,10 +514,10 @@ def get_categories_captures(self, category: str | None=None) -> list[str] | dict :param category: The category according to which the uuids are to be returned ''' - if not category: - url = urljoin(self.root_url, str(PurePosixPath('json', 'categories'))) - else: + if category: url = urljoin(self.root_url, str(PurePosixPath('json', 'categories', category))) + else: + url = urljoin(self.root_url, str(PurePosixPath('json', 'categories'))) r = self.session.get(url) return r.json()