Changeset View
Changeset View
Standalone View
Standalone View
swh/web/client/client.py
Show First 20 Lines • Show All 404 Lines • ▼ Show 20 Lines | ) -> Iterator[Dict[str, Any]]: | ||||
r = self._call(query, http_method="get", params=params, **req_args) | r = self._call(query, http_method="get", params=params, **req_args) | ||||
yield from [typify_json(v, ORIGIN_VISIT) if typify else v for v in r.json()] | yield from [typify_json(v, ORIGIN_VISIT) if typify else v for v in r.json()] | ||||
if "next" in r.links and "url" in r.links["next"]: | if "next" in r.links and "url" in r.links["next"]: | ||||
params = [] | params = [] | ||||
query = r.links["next"]["url"] | query = r.links["next"]["url"] | ||||
else: | else: | ||||
done = True | done = True | ||||
def last_visit(self, origin: str, typify: bool = True) -> Dict[str, Any]: | |||||
"""Return the last visit of an origin. | |||||
Args: | |||||
origin: the URL of a software origin | |||||
typify: if True, convert return value to pythonic types wherever | |||||
possible, otherwise return raw JSON types (default: True) | |||||
Returns: | |||||
The last visit for that origin | |||||
Raises: | |||||
requests.HTTPError: if HTTP request fails | |||||
""" | |||||
query = f"origin/{origin}/visit/latest/" | |||||
r = self._call(query, http_method="get") | |||||
visit = r.json() | |||||
return typify_json(visit, ORIGIN_VISIT) if typify else visit | |||||
def known( | def known( | ||||
self, swhids: Iterator[SWHIDish], **req_args | self, swhids: Iterator[SWHIDish], **req_args | ||||
) -> Dict[CoreSWHID, Dict[Any, Any]]: | ) -> Dict[CoreSWHID, Dict[Any, Any]]: | ||||
"""Verify the presence in the archive of several objects at once | """Verify the presence in the archive of several objects at once | ||||
Args: | Args: | ||||
swhids: SWHIDs of the objects to verify | swhids: SWHIDs of the objects to verify | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |