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

Method __rich__

scratchattach/site/user.py:187–234  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

185 return f"https://scratch.mit.edu/users/{self.username}"
186
187 def __rich__(self):
188 from rich.panel import Panel
189 from rich.table import Table
190 from rich import box
191 from rich.markup import escape
192
193 featured_data = self.featured_data() or {}
194
195 ocular_data = {}
196 # FIXME: ocular is down right now, so this is disabled
197 # ocular_data = self.ocular_status()
198 ocular = "No ocular status"
199
200 if status := ocular_data.get("status"):
201 color_str = ""
202 color_data = ocular_data.get("color")
203 if color_data is not None:
204 color_str = f"[{color_data}] ⬤ [/]"
205
206 ocular = f"[i]{escape(status)}[/]{color_str}"
207
208 _classroom = self.classroom
209 url = f"[link={self.url}]{escape(self.username)}[/]"
210
211 info = Table(box=box.SIMPLE)
212 info.add_column(url, overflow="fold")
213 info.add_column(f"#{self.id}", overflow="fold")
214
215 info.add_row("Joined", escape(self.join_date))
216 info.add_row("Country", escape(self.country))
217 info.add_row("Messages", str(self.message_count()))
218 info.add_row("Class", str(_classroom.title if _classroom is not None else "None"))
219
220 desc = Table("Profile", ocular, box=box.SIMPLE)
221 desc.add_row("About me", escape(self.about_me))
222 desc.add_row("Wiwo", escape(self.wiwo))
223 desc.add_row(
224 escape(featured_data.get("label", "Featured Project")),
225 escape(str(self.connect_featured_project())),
226 )
227
228 ret = Table.grid(expand=True)
229
230 ret.add_column(ratio=1)
231 ret.add_column(ratio=3)
232 ret.add_row(Panel(info, title=url), Panel(desc, title="Description"))
233
234 return ret
235
236 def connect_featured_project(self) -> Optional[project.Project]:
237 data = self.featured_data() or {}

Callers

nothing calls this directly

Calls 4

featured_dataMethod · 0.95
message_countMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected