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

Method comment_by_id

scratchattach/site/project.py:474–493  ·  view source on GitHub ↗

Returns: scratchattach.comments.Comment: A Comment object representing the requested comment.

(self, comment_id)

Source from the content-addressed store, hash-verified

472 return commons.parse_object_list(response, comment.Comment, self._session)
473
474 def comment_by_id(self, comment_id):
475 """
476 Returns:
477 scratchattach.comments.Comment: A Comment object representing the requested comment.
478 """
479 # https://api.scratch.mit.edu/users/TimMcCool/projects/404369790/comments/439984518
480 data = requests.get(
481 f"https://api.scratch.mit.edu/users/{self.author_name}/projects/{self.id}/comments/{comment_id}",
482 headers=self._headers,
483 cookies=self._cookies,
484 ).json()
485
486 if data is None or data.get("code") == "NotFound":
487 raise exceptions.CommentNotFound(f"Cannot find comment #{comment_id} on -P {self.id} by -U {self.author_name}")
488
489 _comment = comment.Comment(
490 id=data["id"], _session=self._session, source=comment.CommentSource.PROJECT, source_id=self.id
491 )
492 _comment._update_from_dict(data)
493 return _comment
494
495 def love(self):
496 """

Callers 2

parent_commentMethod · 0.95
target_commentMethod · 0.95

Calls 3

_update_from_dictMethod · 0.95
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected