swh.fuse.fs.mountpoint module

class swh.fuse.fs.mountpoint.Root(fuse: Fuse)[source]

Bases: swh.fuse.fs.entry.FuseDirEntry

The FUSE mountpoint, consisting of the archive/ and origin/ directories

name: str = ''

entry filename

mode: int = 16749

entry permission mode

depth: int = 1
compute_entries() AsyncIterator[swh.fuse.fs.entry.FuseEntry][source]

Return the child entries of a directory entry

class swh.fuse.fs.mountpoint.ArchiveDir(depth: int, fuse: Fuse)[source]

Bases: swh.fuse.fs.entry.FuseDirEntry

The archive/ virtual directory allows to mount any artifact on the fly using its SWHID as name. The associated metadata of the artifact from the Software Heritage Web API can also be accessed through the SWHID.json file (in case of pagination, the JSON file will contain a complete version with all pages merged together). Note: the archive directory cannot be listed with ls, but entries in it can be accessed (e.g., using cat or cd).

name: str = 'archive'

entry filename

mode: int = 16749

entry permission mode

ENTRIES_REGEXP: Optional[Pattern] = re.compile('^(swh:1:(cnt|dir|rel|rev|snp):[0-9a-f]{40})(.json)?$')
compute_entries() AsyncIterator[swh.fuse.fs.entry.FuseEntry][source]

Return the child entries of a directory entry

async lookup(name: str) Optional[swh.fuse.fs.entry.FuseEntry][source]

Look up a FUSE entry by name

class swh.fuse.fs.mountpoint.MetaEntry(name: str, mode: int, depth: int, fuse: Fuse, swhid: swh.model.swhids.CoreSWHID)[source]

Bases: swh.fuse.fs.entry.FuseFileEntry

An entry for a archive/<SWHID>.json file, containing all the SWHID’s metadata from the Software Heritage archive.

swhid: swh.model.swhids.CoreSWHID
async get_content() bytes[source]

Return the content of a file entry

async size() int[source]

Return the size (in bytes) of an entry

class swh.fuse.fs.mountpoint.OriginDir(depth: int, fuse: Fuse)[source]

Bases: swh.fuse.fs.entry.FuseDirEntry

The origin/ directory is lazily populated with one entry per accessed origin URL (mangled to create a valid UNIX filename). The URL encoding is done using the percent-encoding mechanism described in RFC 3986.

name: str = 'origin'

entry filename

mode: int = 16749

entry permission mode

ENTRIES_REGEXP: Optional[Pattern] = re.compile('^.*%3A.*$')
create_origin_child(url_encoded: str) swh.fuse.fs.entry.FuseEntry[source]
compute_entries() AsyncIterator[swh.fuse.fs.entry.FuseEntry][source]

Return the child entries of a directory entry

async lookup(name: str) Optional[swh.fuse.fs.entry.FuseEntry][source]

Look up a FUSE entry by name

class swh.fuse.fs.mountpoint.CacheDir(depth: int, fuse: Fuse)[source]

Bases: swh.fuse.fs.entry.FuseDirEntry

The cache/ directory is an on-disk representation of locally cached objects and metadata. Via this directory you can browse cached data and selectively remove them from the cache, freeing disk space. (See swh fs clean in the {ref}`CLI <swh-fuse-cli>` to completely empty the cache). The directory is populated with symlinks to: all artifacts, identified by their SWHIDs and sharded by the first two character of their object id, the metadata identified by a SWHID.json entry, and the origin/ directory.

name: str = 'cache'

entry filename

mode: int = 16749

entry permission mode

ENTRIES_REGEXP: Optional[Pattern] = re.compile('^([a-f0-9]{2})|(origin)$')
class ArtifactShardBySwhid(name: 'str', mode: 'int', depth: 'int', fuse: 'Fuse', prefix: str = '')[source]

Bases: swh.fuse.fs.entry.FuseDirEntry

ENTRIES_REGEXP: Optional[Pattern] = re.compile('^(swh:1:(cnt|dir|rel|rev|snp):[0-9a-f]{40})$')
prefix: str = ''
compute_entries() AsyncIterator[swh.fuse.fs.entry.FuseEntry][source]

Return the child entries of a directory entry

compute_entries() AsyncIterator[swh.fuse.fs.entry.FuseEntry][source]

Return the child entries of a directory entry

class swh.fuse.fs.mountpoint.Readme(depth: int, fuse: Fuse)[source]

Bases: swh.fuse.fs.entry.FuseFileEntry

Top-level README to explain briefly what is SwhFS.

name: str = 'README'

entry filename

mode: int = 33060

entry permission mode

CONTENT = 'Welcome to the Software Heritage Filesystem (SwhFS)!\n\nThis is a user-space POSIX filesystem to browse the Software Heritage archive,\nas if it were locally available. The SwhFS mount point contains 3 directories,\nall initially empty and lazily populated:\n\n- "archive": virtual directory to mount any Software Heritage artifact on the\n  fly using its SWHID as name. Note: this directory cannot be listed with ls,\n  but entries in it can be accessed (e.g., using cat or cd).\n- "origin": virtual directory to mount any origin using its encoded URL as name.\n- "cache": on-disk representation of locally cached objects and metadata.\n\nTry it yourself:\n\n    $ cat archive/swh:1:cnt:c839dea9e8e6f0528b468214348fee8669b305b2\n    #include <stdio.h>\n\n    int main(void) {\n        printf("Hello, World!\\n");\n    }\n\nYou can find more details and examples in the SwhFS online documentation:\nhttps://docs.softwareheritage.org/devel/swh-fuse/ '
async get_content() bytes[source]

Return the content of a file entry