swh.web.browse.snapshot_context module

swh.web.browse.snapshot_context.process_snapshot_branches(snapshot: Dict[str, Any]) → Tuple[List[swh.web.common.typing.SnapshotBranchInfo], List[swh.web.common.typing.SnapshotReleaseInfo]][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.common.service.lookup_snapshot()

Returns

A tuple whose first member is the sorted list of branches targeting revisions and second member the sorted list of branches targeting releases

swh.web.browse.snapshot_context.get_snapshot_content(snapshot_id: str) → Tuple[List[swh.web.common.typing.SnapshotBranchInfo], List[swh.web.common.typing.SnapshotReleaseInfo]][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 two 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.

Raises

NotFoundExc if the snapshot does not exist

swh.web.browse.snapshot_context.get_origin_visit_snapshot(origin_info: swh.web.common.typing.OriginInfo, visit_ts: Optional[str] = None, visit_id: Optional[int] = None, snapshot_id: Optional[str] = None) → Tuple[List[swh.web.common.typing.SnapshotBranchInfo], List[swh.web.common.typing.SnapshotReleaseInfo]][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 two 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.

Raises

NotFoundExc if the origin or its visit are not found

swh.web.browse.snapshot_context.get_snapshot_context(snapshot_id: Optional[str] = None, origin_url: Optional[str] = None, timestamp: Optional[str] = None, visit_id: Optional[int] = None, branch_name: Optional[str] = None, release_name: Optional[str] = None, revision_id: Optional[str] = None, path: Optional[str] = None, browse_context: str = 'directory')swh.web.common.typing.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.common.exc.NotFoundExc – if no snapshot is found for the visit of an origin.

swh.web.browse.snapshot_context.browse_snapshot_directory(request, snapshot_id=None, origin_url=None, timestamp=None, path=None)[source]

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

swh.web.browse.snapshot_context.browse_snapshot_content(request, snapshot_id=None, origin_url=None, timestamp=None, path=None, selected_language=None)[source]

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

swh.web.browse.snapshot_context.browse_snapshot_log(request, snapshot_id=None, origin_url=None, timestamp=None)[source]

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

swh.web.browse.snapshot_context.browse_snapshot_branches(request, snapshot_id=None, origin_url=None, timestamp=None)[source]

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

swh.web.browse.snapshot_context.browse_snapshot_releases(request, snapshot_id=None, origin_url=None, timestamp=None)[source]

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