Fix case for ZeroDate and PresenceOrder
Only top-level types should have CaseLikeThis, general top-level variables should be LIKE_THAT.
This commit is contained in:
parent
f03ac77595
commit
8d93433a8e
|
@ -40,7 +40,7 @@ from .errors import (
|
||||||
from .html_markdown import HTML_PROCESSOR as HTML
|
from .html_markdown import HTML_PROCESSOR as HTML
|
||||||
from .media_cache import Media, Thumbnail
|
from .media_cache import Media, Thumbnail
|
||||||
from .models.items import (
|
from .models.items import (
|
||||||
Account, Event, Member, Presence, Room, Upload, UploadStatus, ZeroDate,
|
Account, Event, Member, Presence, Room, Upload, UploadStatus, ZERO_DATE,
|
||||||
)
|
)
|
||||||
from .models.model_store import ModelStore
|
from .models.model_store import ModelStore
|
||||||
from .nio_callbacks import NioCallbacks
|
from .nio_callbacks import NioCallbacks
|
||||||
|
@ -1397,7 +1397,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
model.clear()
|
model.clear()
|
||||||
|
|
||||||
self.models[self.user_id, "rooms"][room_id].last_event_date = \
|
self.models[self.user_id, "rooms"][room_id].last_event_date = \
|
||||||
ZeroDate
|
ZERO_DATE
|
||||||
|
|
||||||
|
|
||||||
async def devices_info(self) -> List[Dict[str, Any]]:
|
async def devices_info(self) -> List[Dict[str, Any]]:
|
||||||
|
@ -1431,7 +1431,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
"id": device.id,
|
"id": device.id,
|
||||||
"display_name": device.display_name or "",
|
"display_name": device.display_name or "",
|
||||||
"last_seen_ip": (device.last_seen_ip or "").strip(" -"),
|
"last_seen_ip": (device.last_seen_ip or "").strip(" -"),
|
||||||
"last_seen_date": device.last_seen_date or ZeroDate,
|
"last_seen_date": device.last_seen_date or ZERO_DATE,
|
||||||
"last_seen_country": "",
|
"last_seen_country": "",
|
||||||
"type": get_type(device.id),
|
"type": get_type(device.id),
|
||||||
"ed25519_key": get_ed25519(device.id),
|
"ed25519_key": get_ed25519(device.id),
|
||||||
|
|
|
@ -15,9 +15,11 @@ import nio
|
||||||
from ..utils import AutoStrEnum, auto
|
from ..utils import AutoStrEnum, auto
|
||||||
from .model_item import ModelItem
|
from .model_item import ModelItem
|
||||||
|
|
||||||
ZeroDate = datetime.fromtimestamp(0)
|
|
||||||
OptionalExceptionType = Union[Type[None], Type[Exception]]
|
OptionalExceptionType = Union[Type[None], Type[Exception]]
|
||||||
PresenceOrder: Dict[str, int] = {
|
|
||||||
|
ZERO_DATE = datetime.fromtimestamp(0)
|
||||||
|
|
||||||
|
PRESENCE_ORDER: Dict[str, int] = {
|
||||||
"online": 0,
|
"online": 0,
|
||||||
"unavailable": 1,
|
"unavailable": 1,
|
||||||
"offline": 2,
|
"offline": 2,
|
||||||
|
@ -76,12 +78,12 @@ class Presence:
|
||||||
echo_invisible = auto()
|
echo_invisible = auto()
|
||||||
|
|
||||||
def __lt__(self, other: "Presence.State") -> bool:
|
def __lt__(self, other: "Presence.State") -> bool:
|
||||||
return PresenceOrder[self.value] < PresenceOrder[other.value]
|
return PRESENCE_ORDER[self.value] < PRESENCE_ORDER[other.value]
|
||||||
|
|
||||||
|
|
||||||
presence: State = State.offline
|
presence: State = State.offline
|
||||||
currently_active: bool = False
|
currently_active: bool = False
|
||||||
last_active_at: datetime = ZeroDate
|
last_active_at: datetime = ZERO_DATE
|
||||||
status_msg: str = ""
|
status_msg: str = ""
|
||||||
|
|
||||||
members: Dict[str, "Member"] = field(default_factory=dict)
|
members: Dict[str, "Member"] = field(default_factory=dict)
|
||||||
|
@ -131,7 +133,7 @@ class Account(ModelItem):
|
||||||
display_name: str = ""
|
display_name: str = ""
|
||||||
avatar_url: str = ""
|
avatar_url: str = ""
|
||||||
max_upload_size: int = 0
|
max_upload_size: int = 0
|
||||||
profile_updated: datetime = ZeroDate
|
profile_updated: datetime = ZERO_DATE
|
||||||
connecting: bool = False
|
connecting: bool = False
|
||||||
total_unread: int = 0
|
total_unread: int = 0
|
||||||
total_highlights: int = 0
|
total_highlights: int = 0
|
||||||
|
@ -143,7 +145,7 @@ class Account(ModelItem):
|
||||||
presence_support: bool = False
|
presence_support: bool = False
|
||||||
presence: Presence.State = Presence.State.offline
|
presence: Presence.State = Presence.State.offline
|
||||||
currently_active: bool = False
|
currently_active: bool = False
|
||||||
last_active_at: datetime = ZeroDate
|
last_active_at: datetime = ZERO_DATE
|
||||||
status_msg: str = ""
|
status_msg: str = ""
|
||||||
|
|
||||||
def __lt__(self, other: "Account") -> bool:
|
def __lt__(self, other: "Account") -> bool:
|
||||||
|
@ -187,7 +189,7 @@ class Room(ModelItem):
|
||||||
can_set_join_rules: bool = False
|
can_set_join_rules: bool = False
|
||||||
can_set_guest_access: bool = False
|
can_set_guest_access: bool = False
|
||||||
|
|
||||||
last_event_date: datetime = ZeroDate
|
last_event_date: datetime = ZERO_DATE
|
||||||
|
|
||||||
unreads: int = 0
|
unreads: int = 0
|
||||||
highlights: int = 0
|
highlights: int = 0
|
||||||
|
@ -273,14 +275,14 @@ class Member(ModelItem):
|
||||||
typing: bool = False
|
typing: bool = False
|
||||||
power_level: int = 0
|
power_level: int = 0
|
||||||
invited: bool = False
|
invited: bool = False
|
||||||
profile_updated: datetime = ZeroDate
|
profile_updated: datetime = ZERO_DATE
|
||||||
|
|
||||||
last_read_event: str = ""
|
last_read_event: str = ""
|
||||||
last_read_at: datetime = ZeroDate
|
last_read_at: datetime = ZERO_DATE
|
||||||
|
|
||||||
presence: Presence.State = Presence.State.offline
|
presence: Presence.State = Presence.State.offline
|
||||||
currently_active: bool = False
|
currently_active: bool = False
|
||||||
last_active_at: datetime = ZeroDate
|
last_active_at: datetime = ZERO_DATE
|
||||||
status_msg: str = ""
|
status_msg: str = ""
|
||||||
|
|
||||||
def __lt__(self, other: "Member") -> bool:
|
def __lt__(self, other: "Member") -> bool:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user