KaraKaraWitch commited on
Commit
1af74bb
·
verified ·
1 Parent(s): 8536e7c

Upload Scripts/RedditModels.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. Scripts/RedditModels.py +71 -0
Scripts/RedditModels.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional
2
+
3
+ import msgspec
4
+
5
+
6
+ class RedditFlair(msgspec.Struct):
7
+ bg: Optional[str] = ""
8
+ css_cls: Optional[str] = ""
9
+ richtext: Optional[str | list | dict] = ""
10
+ template: Optional[str] = ""
11
+ text: Optional[str] = ""
12
+ text_color: Optional[str] = ""
13
+ type: Optional[str] = ""
14
+
15
+ @property
16
+ def is_flaired(self):
17
+ checks = [
18
+ self.bg,
19
+ self.css_cls,
20
+ self.richtext,
21
+ self.template,
22
+ self.text,
23
+ self.text_color,
24
+ ]
25
+ checks = [True if chk else False for chk in checks]
26
+ if sum(checks) > 1:
27
+ return True
28
+ return False
29
+
30
+
31
+ class RedditAuthor(msgspec.Struct):
32
+ name: str
33
+ uid: str
34
+ create: int
35
+ flair: Optional[RedditFlair] = None
36
+ patreon: bool = False
37
+ premium: bool = False
38
+
39
+
40
+ class RedditSubreddit(msgspec.Struct):
41
+ name: str
42
+ id: str
43
+ subs: int | None
44
+ type: str | None
45
+
46
+
47
+ class RedditSubmit(msgspec.Struct):
48
+ sub: RedditSubreddit
49
+ author: RedditAuthor | None
50
+ title: str | None
51
+ score: int | None
52
+ created: int | float
53
+ id: str | None
54
+ flags: str = ""
55
+ link_flair: Optional[RedditFlair] = None
56
+ url: Optional[str] = ""
57
+ text: Optional[str] = None
58
+ removed: list[str | None] | None = []
59
+ cross: list["RedditSubmit"] = []
60
+
61
+
62
+ class RedditComment(msgspec.Struct):
63
+ sub: RedditSubreddit
64
+ author: RedditAuthor | None
65
+ text: str | None
66
+ score: int
67
+ created: int | float
68
+ id: str
69
+ parent_id: str
70
+ thread_id: str
71
+ flags: str = ""