swh.storage.algos.swhid module#

swh.storage.algos.swhid.known_swhids(storage: StorageInterface, swhids: Iterable[T]) set[T][source]#

Query the storage to check if swhids exist.

We group SWHIDs by type and then call the corresponding storage _missing method (directory_missing, snapshot_missing, etc.) and switch the results as we want to know what exists, not what’s missing.

As the storage does not use values from the qualifier (snapshot, etc.) we exclude QualifiedSWHID from this method because known_swhids(storage, swh:1:cnt:1234567890;visit=swh:1:snp:098654321) could return that swh:1:cnt:1234567890 exists even if swh:1:snp:098654321 doesn’t.

Parameters:
  • storage – a StorageInterface

  • swhid – a list of SWHIDs

Raises:

TypeError – received a QualifiedSWHID in the swhids list

Returns:

A set of SWHIDs found in the storage

swh.storage.algos.swhid.swhid_is_known(storage: StorageInterface, swhid: CoreSWHID | ExtendedSWHID) bool[source]#

Query the storage to check if swhid exists.

A wrapper for known_swhids() but for a single SWHID.

Parameters:
  • storage – a StorageInterface

  • swhid – a SWHID

Returns:

True if swhid exists in the storage