Skip to content

Commit

Permalink
chg: Avoid if not when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Jul 23, 2024
1 parent 5664720 commit f08114a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pylookyloo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()

Expand Down

0 comments on commit f08114a

Please sign in to comment.