diff options
author | mia <mia@mia.jetzt> | 2024-09-04 04:47:13 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-09-04 04:47:13 -0700 |
commit | bb8a48fd4d85ba4f8224c68aaaf9069d5d79dae2 (patch) | |
tree | bdb0654c667f37c69addc9efd1e29b9cfe710c51 /ty.py | |
parent | 81071e8feefdf815e29318226c668664e1706da2 (diff) | |
download | scrubber-bb8a48fd4d85ba4f8224c68aaaf9069d5d79dae2.tar.gz scrubber-bb8a48fd4d85ba4f8224c68aaaf9069d5d79dae2.zip |
desktop changes
Diffstat (limited to 'ty.py')
-rw-r--r-- | ty.py | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/ty.py b/ty.py deleted file mode 100644 index e17c046..0000000 --- a/ty.py +++ /dev/null @@ -1,61 +0,0 @@ -from dataclasses import dataclass -from typing import List, Callable -from datetime import datetime -from enum import Enum - -class Visibility(Enum): - public = 1 - unlisted = 2 - followers = 3 - direct = 4 - - @classmethod - def from_db(cls, raw: str) -> "Visibility": - match raw: - case "public": return cls.public - case "home": return cls.unlisted - case "followers": return cls.followers - case "specified": return cls.direct - case _: raise ValueError(f"unknown visibility `{raw}`") - - -@dataclass -class FilterableNote: - id: str - mine: bool - replies: List["FilterableNote"] - quotes: List["FilterableNote"] - when: datetime - reactions: int - renotes: int - visibility: Visibility - - def thread(self) -> List["FilterableNote"]: - acc = [] - for reply in self.replies: - acc += reply.thread() - for quote in self.quotes: - acc += quote.thread() - acc.append(self) - return acc - - def thread_self(self) -> List["FilterableNote"]: - acc = [] - for reply in self.replies: - acc += reply.thread_self() - for quote in self.quotes: - acc += quote.thread_self() - if self.mine: - acc.append(self) - return acc - - def to_dict(self): - return { - "id": self.id, - "mine": self.mine, - "replies": [note.to_dict() for note in self.replies], - "quotes": [note.to_dict() for note in self.quotes], - "when": self.when.isoformat(), - "reactions": self.reactions, - "renotes": self.renotes, - } |