MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / Session

Class Session

scratchattach/site/session.py:74–1299  ·  view source on GitHub ↗

Represents a Scratch log in / session. Stores authentication data (session id and xtoken). Attributes: id: The session id associated with the login username: The username associated with the login xtoken: The xtoken associated with the login email: The email

Source from the content-addressed store, hash-verified

72
73@dataclass
74class Session(BaseSiteComponent):
75 """
76 Represents a Scratch log in / session. Stores authentication data (session id and xtoken).
77
78 Attributes:
79 id: The session id associated with the login
80 username: The username associated with the login
81 xtoken: The xtoken associated with the login
82 email: The email address associated with the logged in account
83 new_scratcher: True if the associated account is a new Scratcher
84 mute_status: Information about commenting restrictions of the associated account
85 banned: Returns True if the associated account is banned
86 """
87
88 username: str = field(repr=False, default="")
89 _user: Optional[user.User] = field(repr=False, default=None)
90
91 id: str = field(repr=False, default="")
92 session_string: Optional[str] = field(repr=False, default=None)
93 xtoken: Optional[str] = field(repr=False, default=None)
94 email: Optional[str] = field(repr=False, default=None)
95
96 new_scratcher: bool = field(repr=False, default=False)
97 mute_status: Any = field(repr=False, default=None)
98 banned: bool = field(repr=False, default=False)
99
100 time_created: datetime.datetime = field(repr=False, default=datetime.datetime.fromtimestamp(0.0))
101 language: str = field(repr=False, default="en")
102
103 has_outstanding_email_confirmation: bool = field(repr=False, default=False)
104 is_teacher: bool = field(repr=False, default=False)
105 is_teacher_invitee: bool = field(repr=False, default=False)
106 ocular_token: Optional[str] = field(repr=False, default=None) # note that this is a header, not a cookie
107 _session: Optional[Session] = field(kw_only=True, default=None)
108
109 def __str__(self) -> str:
110 return f"-L {self.username}"
111
112 def __rich__(self):
113 from rich.panel import Panel
114 from rich.table import Table
115 from rich import box
116 from rich.markup import escape
117
118 try:
119 self.update()
120 except KeyError as e:
121 warnings.warn(f"Ignored KeyError: {e}")
122
123 ret = Table(
124 f"[link={self.connect_linked_user().url}]{escape(self.username)}[/]", f"Created: {self.time_created}", expand=True
125 )
126
127 ret.add_row("Email", escape(str(self.email)))
128 ret.add_row("Language", escape(str(self.language)))
129 ret.add_row("Mute status", escape(str(self.mute_status)))
130 ret.add_row("New scratcher?", str(self.new_scratcher))
131 ret.add_row("Banned?", str(self.banned))

Callers 1

login_by_idFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected