swh.web.browse.snapshot_context module#

swh.web.browse.snapshot_context.process_snapshot_branches(snapshot: Dict[str, Any], discard_messages: bool = False) Tuple[List[SnapshotBranchInfo], List[SnapshotReleaseInfo], Dict[str, Any]][source]#

Process a dictionary describing snapshot branches: extract those targeting revisions and releases, put them in two different lists, then sort those lists in lexicographical order of the branches’ names.

Parameters:
  • snapshot – a dict describing a snapshot as returned for instance by swh.web.utils.archive.lookup_snapshot()

  • discard_messages – if True, do not retrieve messages associated to branches and releases

Returns:

A tuple whose first member is the sorted list of branches targeting revisions, second member the sorted list of branches targeting releases and third member a dict mapping resolved branch aliases to their real target.

swh.web.browse.snapshot_context.get_snapshot_content(snapshot_id: str) Tuple[List[SnapshotBranchInfo], List[SnapshotReleaseInfo], Dict[str, Any]][source]#

Returns the lists of branches and releases associated to a swh snapshot. That list is put in cache in order to speedup the navigation in the swh-web/browse ui.

Warning

At most 1000 branches contained in the snapshot will be returned for performance reasons.

Parameters:

snapshot_id – hexadecimal representation of the snapshot identifier

Returns:

A tuple with three members. The first one is a list of dict describing the snapshot branches. The second one is a list of dict describing the snapshot releases. The third one is a dict mapping resolved branch aliases to their real target.

Raises:

NotFoundExc if the snapshot does not exist

swh.web.browse.snapshot_context.get_origin_visit_snapshot(origin_info: OriginInfo, visit_ts: str | None = None, visit_id: int | None = None, snapshot_id: str | None = None) Tuple[List[SnapshotBranchInfo], List[SnapshotReleaseInfo], Dict[str, Any]][source]#

Returns the lists of branches and releases associated to an origin for a given visit.

The visit is expressed by either:

  • a snapshot identifier

  • a timestamp, if no visit with that exact timestamp is found, the closest one from the provided timestamp will be used.

If no visit parameter is provided, it returns the list of branches found for the latest visit.

That list is put in cache in order to speedup the navigation in the swh-web/browse ui.

Warning

At most 1000 branches contained in the snapshot will be returned for performance reasons.

Parameters:
  • origin_info – a dict filled with origin information

  • visit_ts – an ISO 8601 datetime string to parse

  • visit_id – visit id for disambiguation in case several visits have the same timestamp

  • snapshot_id – if provided, visit associated to the snapshot will be processed

Returns:

A tuple with three members. The first one is a list of dict describing the origin branches for the given visit. The second one is a list of dict describing the origin releases for the given visit. The third one is a dict mapping resolved branch aliases to their real target.

Raises:

NotFoundExc if the origin or its visit are not found

swh.web.browse.snapshot_context.get_snapshot_context(snapshot_id: str | None = None, origin_url: str | None = None, timestamp: str | None = None, visit_id: int | None = None, branch_name: str | None = None, release_name: str | None = None, revision_id: str | None = None, path: str | None = None, browse_context: str = 'directory', visit_type: str | None = None) SnapshotContext[source]#

Utility function to compute relevant information when navigating the archive in a snapshot context. The snapshot is either referenced by its id or it will be retrieved from an origin visit.

Parameters:
  • snapshot_id – hexadecimal representation of a snapshot identifier

  • origin_url – an origin_url

  • timestamp – a datetime string for retrieving the closest visit of the origin

  • visit_id – optional visit id for disambiguation in case of several visits with the same timestamp

  • branch_name – optional branch name set when browsing the snapshot in that scope (will default to “HEAD” if not provided)

  • release_name – optional release name set when browsing the snapshot in that scope

  • revision_id – optional revision identifier set when browsing the snapshot in that scope

  • path – optional path of the object currently browsed in the snapshot

  • browse_context – indicates which type of object is currently browsed

Returns:

A dict filled with snapshot context information.

Raises:

swh.web.utils.exc.NotFoundExc – if no snapshot is found for the visit of an origin.

swh.web.browse.snapshot_context.browse_snapshot_directory(request: HttpRequest, snapshot_id: str | None = None, origin_url: str | None = None, timestamp: str | None = None, path: str | None = None) HttpResponse[source]#

Django view implementation for browsing a directory in a snapshot context.

swh.web.browse.snapshot_context.browse_snapshot_log(request: HttpRequest, snapshot_id: str | None = None, origin_url: str | None = None, timestamp: str | None = None) HttpResponse[source]#

Django view implementation for browsing a revision history in a snapshot context.

swh.web.browse.snapshot_context.browse_snapshot_branches(request: HttpRequest, snapshot_id: str | None = None, origin_url: str | None = None, timestamp: str | None = None, branch_name_include: str | None = None) HttpResponse[source]#

Django view implementation for browsing a list of branches in a snapshot context.

swh.web.browse.snapshot_context.browse_snapshot_releases(request: HttpRequest, snapshot_id: str | None = None, origin_url: str | None = None, timestamp: str | None = None, release_name_include: str | None = None)[source]#

Django view implementation for browsing a list of releases in a snapshot context.