From 0e01b354000e39714f2dca78ba8ddf98769864d6 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Fri, 22 Jun 2018 22:39:08 +0200 Subject: [PATCH] Add a new `fetch_remote_activity` helper --- little_boxes/activitypub.py | 4 ++++ little_boxes/errors.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/little_boxes/activitypub.py b/little_boxes/activitypub.py index 7b7e3c6..b679679 100644 --- a/little_boxes/activitypub.py +++ b/little_boxes/activitypub.py @@ -1056,6 +1056,10 @@ class Note(BaseActivity): ) +def fetch_remote_activity(iri: str, expected: Optional[ActivityType]) -> BaseActivity: + return parse_activity(get_backend().fetch_iri(iri), expected=expected) + + class Box(object): def __init__(self, actor: Person) -> None: self.actor = actor diff --git a/little_boxes/errors.py b/little_boxes/errors.py index e90905c..9804c0b 100644 --- a/little_boxes/errors.py +++ b/little_boxes/errors.py @@ -26,13 +26,13 @@ class Error(Exception): rv["message"] = self.message return rv - def __repr__(self) -> str: + def __repr__(self) -> str: # pragma: no cover return ( f"{self.__class__.__qualname__}({self.message!r}, " f"payload={self.payload!r}, status_code={self.status_code})" ) - def __str__(self) -> str: + def __str__(self) -> str: # pragma: no cover return self.__repr__()