swh.fuse.backends.compressed module#

swh.fuse.backends.compressed.decode_or_base64(data: bytes) str[source]#

If data is not proper UTF-8, return it as base64.

class swh.fuse.backends.compressed.CompressedGraphBackend(conf: dict)[source]#

Bases: GraphBackend

A Backend querying a compressed graph instance via gRPC.

Only needs graph.grpc-url.

async get_metadata(swhid: CoreSWHID) Dict | List[source]#

Entries in the returned dict depend on the swhid type.

For cnt, return a dict containing at least 'length': [int]

For dir, return a list of entries like

{
    "dir_id": "dir's hash",
    "name": "dir item name",
    "type": "str=dir|file|rev",  # yes, `file`...
    "target": "target hash",
    "perms": "permissions [int]",
    # if target is a cnt:
    "length": "file size [int]",
}

For rev, return a dict containing at least directory (SWHID), parents (list of objects containing at list id (hash)), date (str, isoformat), committer_date (str, isoformat), id` (object’s hash).

For rel, return a dict containing at least target (SWHID), target_type, date (str, isoformat), id (object’s hash).

For snp, return a dict where each key is a branch name, each value is a dict containing at least target (hash), target_type (content, directory, revision, release, snapshot or alias).

async get_history(swhid: CoreSWHID) List[Tuple[str, str]][source]#

Return a list of tuples (swhid, revision swhid)

async get_visits(url_encoded: str) List[Dict[str, Any]][source]#

Return a list of objects

Each object should contain fields date (ISO), origin (str), snapshot (SWHID’s hash as str)