KaraKaraWitch's picture
Upload Scripts/RedditModels.py with huggingface_hub
1af74bb verified
from typing import Optional
import msgspec
class RedditFlair(msgspec.Struct):
bg: Optional[str] = ""
css_cls: Optional[str] = ""
richtext: Optional[str | list | dict] = ""
template: Optional[str] = ""
text: Optional[str] = ""
text_color: Optional[str] = ""
type: Optional[str] = ""
@property
def is_flaired(self):
checks = [
self.bg,
self.css_cls,
self.richtext,
self.template,
self.text,
self.text_color,
]
checks = [True if chk else False for chk in checks]
if sum(checks) > 1:
return True
return False
class RedditAuthor(msgspec.Struct):
name: str
uid: str
create: int
flair: Optional[RedditFlair] = None
patreon: bool = False
premium: bool = False
class RedditSubreddit(msgspec.Struct):
name: str
id: str
subs: int | None
type: str | None
class RedditSubmit(msgspec.Struct):
sub: RedditSubreddit
author: RedditAuthor | None
title: str | None
score: int | None
created: int | float
id: str | None
flags: str = ""
link_flair: Optional[RedditFlair] = None
url: Optional[str] = ""
text: Optional[str] = None
removed: list[str | None] | None = []
cross: list["RedditSubmit"] = []
class RedditComment(msgspec.Struct):
sub: RedditSubreddit
author: RedditAuthor | None
text: str | None
score: int
created: int | float
id: str
parent_id: str
thread_id: str
flags: str = ""