mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
style: reformat
This commit is contained in:
parent
3344ab7c5d
commit
c77191864e
|
@ -27,6 +27,7 @@ class TokenInfoWithIsCaller(BaseModel):
|
|||
date: datetime
|
||||
is_caller: bool
|
||||
|
||||
|
||||
def _naive(date_time: datetime) -> datetime:
|
||||
if date_time is None:
|
||||
return None
|
||||
|
@ -34,6 +35,7 @@ def _naive(date_time: datetime) -> datetime:
|
|||
date_time.astimezone(timezone.utc)
|
||||
return date_time.replace(tzinfo=None)
|
||||
|
||||
|
||||
def get_api_tokens_with_caller_flag(caller_token: str) -> list[TokenInfoWithIsCaller]:
|
||||
"""Get the tokens info"""
|
||||
caller_name = TOKEN_REPO.get_token_by_token_string(caller_token).device_name
|
||||
|
@ -91,9 +93,6 @@ class RecoveryTokenStatus(BaseModel):
|
|||
uses_left: Optional[int] = None
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_api_recovery_token_status() -> RecoveryTokenStatus:
|
||||
"""Get the recovery token status"""
|
||||
token = TOKEN_REPO.get_recovery_key()
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
def is_past(dt: datetime) -> bool:
|
||||
# we cannot compare a naive now()
|
||||
# to dt which might be tz-aware or unaware
|
||||
dt = ensure_timezone(dt)
|
||||
return dt < datetime.now(timezone.utc)
|
||||
|
||||
def ensure_timezone(dt:datetime) -> datetime:
|
||||
|
||||
def ensure_timezone(dt: datetime) -> datetime:
|
||||
if dt.tzinfo is None or dt.tzinfo.utcoffset(None) is None:
|
||||
dt = dt.replace(tzinfo= timezone.utc)
|
||||
return dt
|
||||
|
||||
dt = dt.replace(tzinfo=timezone.utc)
|
||||
return dt
|
||||
|
|
Loading…
Reference in a new issue