Metadata-Version: 2.4
Name: ratarmountcore
Version: 0.10.2
Summary: Random Access To Archived Resources Library
Author-email: Maximilian Knespel <mxmlnknp@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/mxmlnkn/ratarmount/ratarmountcore
Classifier: License :: OSI Approved :: MIT License
Classifier: Development Status :: 4 - Beta
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Archiving
Classifier: Topic :: System :: Archiving :: Compression
Classifier: Topic :: System :: Filesystems
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: ratarmountcore/_external/pyfatfs/LICENSE
Provides-Extra: full
Requires-Dist: rich; extra == "full"
Requires-Dist: indexed_gzip~=1.7; extra == "full"
Requires-Dist: indexed_zstd<2.0,>=1.3.1; sys_platform == "darwin" and extra == "full"
Requires-Dist: indexed_zstd<2.0,>=1.2.2; platform_system != "Windows" and extra == "full"
Requires-Dist: libarchive-c<6.0,~=5.1; extra == "full"
Requires-Dist: python-xz~=0.4.0; extra == "full"
Requires-Dist: rapidgzip~=0.15.0; extra == "full"
Requires-Dist: rarfile~=4.1; extra == "full"
Requires-Dist: py7zr~=1.0; extra == "full"
Requires-Dist: PySquashfsImage==0.9.0; extra == "full"
Requires-Dist: lz4~=4.0.0; extra == "full"
Requires-Dist: python-lzo~=1.0; extra == "full"
Requires-Dist: zstandard<=0.24.0,>=0.23.0; python_version < "3.14" and extra == "full"
Requires-Dist: zstandard~=0.24.0; python_version >= "3.14" and extra == "full"
Requires-Dist: isal~=1.0; python_version < "3.14.0" and extra == "full"
Requires-Dist: fast_zip_decryption; extra == "full"
Requires-Dist: pygit2; extra == "full"
Requires-Dist: requests; extra == "full"
Requires-Dist: aiohttp; extra == "full"
Requires-Dist: sshfs; extra == "full"
Requires-Dist: pyopenssl>=23; extra == "full"
Requires-Dist: smbprotocol; extra == "full"
Requires-Dist: dropboxdrivefs; extra == "full"
Requires-Dist: fsspec; extra == "full"
Requires-Dist: ipfsspec; extra == "full"
Requires-Dist: s3fs; extra == "full"
Requires-Dist: webdav4; extra == "full"
Provides-Extra: colors
Requires-Dist: rich; extra == "colors"
Provides-Extra: bzip2
Requires-Dist: rapidgzip~=0.15.0; extra == "bzip2"
Provides-Extra: git
Requires-Dist: pygit2; extra == "git"
Provides-Extra: gzip
Requires-Dist: rapidgzip~=0.15.0; extra == "gzip"
Requires-Dist: indexed_gzip~=1.7; extra == "gzip"
Provides-Extra: fsspec
Requires-Dist: fsspec; extra == "fsspec"
Provides-Extra: fsspec-backends
Requires-Dist: requests; extra == "fsspec-backends"
Requires-Dist: aiohttp; extra == "fsspec-backends"
Requires-Dist: sshfs; extra == "fsspec-backends"
Requires-Dist: pyopenssl>=23; extra == "fsspec-backends"
Requires-Dist: smbprotocol; extra == "fsspec-backends"
Requires-Dist: dropboxdrivefs; extra == "fsspec-backends"
Requires-Dist: fsspec; extra == "fsspec-backends"
Requires-Dist: ipfsspec; extra == "fsspec-backends"
Requires-Dist: s3fs; extra == "fsspec-backends"
Requires-Dist: webdav4; extra == "fsspec-backends"
Provides-Extra: rar
Requires-Dist: rarfile~=4.1; extra == "rar"
Provides-Extra: sqlar
Requires-Dist: cryptography; extra == "sqlar"
Requires-Dist: sqlcipher3-wheels; extra == "sqlar"
Provides-Extra: squashfs
Requires-Dist: PySquashfsImage==0.9.0; extra == "squashfs"
Requires-Dist: lz4~=4.0.0; extra == "squashfs"
Requires-Dist: python-lzo~=1.0; extra == "squashfs"
Requires-Dist: zstandard~=0.23.0; (python_version >= "3.8" and python_version < "3.14") and extra == "squashfs"
Requires-Dist: isal~=1.0; python_version < "3.14.0" and extra == "squashfs"
Provides-Extra: xz
Requires-Dist: python-xz~=0.4.0; extra == "xz"
Provides-Extra: zip
Requires-Dist: fast_zip_decryption; extra == "zip"
Provides-Extra: zstd
Requires-Dist: indexed_zstd<2.0,>=1.3.1; sys_platform == "darwin" and extra == "zstd"
Requires-Dist: indexed_zstd<2.0,>=1.2.2; platform_system != "Windows" and extra == "zstd"
Provides-Extra: 7z
Requires-Dist: libarchive-c<6.0,~=5.1; extra == "7z"
Requires-Dist: py7zr~=1.0; extra == "7z"
Provides-Extra: fat
Provides-Extra: ext4
Requires-Dist: ext4~=1.1; extra == "ext4"
Provides-Extra: full-ssh
Requires-Dist: sshfs[bcrypt]; extra == "full-ssh"
Requires-Dist: sshfs[fido2]; extra == "full-ssh"
Requires-Dist: sshfs[gssapi]; extra == "full-ssh"
Requires-Dist: sshfs[libnacl]; extra == "full-ssh"
Requires-Dist: sshfs[python-pkcs11]; extra == "full-ssh"
Requires-Dist: sshfs[pyOpenSSL]; extra == "full-ssh"
Dynamic: license-file

# Random Access Read-Only Tar Mount (Ratarmount) Library

[![PyPI version](https://badge.fury.io/py/ratarmountcore.svg)](https://badge.fury.io/py/ratarmountcore)
[![Python Version](https://img.shields.io/pypi/pyversions/ratarmountcore)](https://pypi.org/project/ratarmountcore/)
[![Downloads](https://static.pepy.tech/badge/ratarmountcore/month)](https://pepy.tech/project/ratarmountcore)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)
[![Changelog](https://img.shields.io/badge/Changelog-Markdown-blue)](https://github.com/mxmlnkn/ratarmount/blob/master/core/CHANGELOG.md)

This is the library used as backend by ratarmount (CLI).
For a full description including motivation and performance comparisons, see [ratarmount](https://github.com/mxmlnkn/ratarmount).


# Table of Contents

1. [Installation](#installation)
2. [Usage](#usage)


# Installation


## PIP Package Installation

In many cases a simple pip install should work:

```bash
pip install ratarmountcore[full]
```

If there is trouble with one of the compression dependencies, first try installing it without dependencies:

```bash
pip install ratarmountcore
```

And if that works, only install those dependencies you need, e.g.:

```bash
pip install ratarmountcore[bzip2,gzip]
```

You can install the latest development version with:

```bash
python3 -m pip install --user --force-reinstall 'git+https://github.com/mxmlnkn/ratarmount.git@develop#egginfo=ratarmountcore&subdirectory=core'
```


## Dependencies

Python 3.6+ and preferably pip 19.0+ are required.
These should be preinstalled on most systems.

Ratarmountcore has as few required dependencies as necessary in order to cause the least troubles on all possible systems.
This means that only uncompressed TAR and ZIP support will work by default.
All optional dependencies are offered as extras.


## Extras

Ratarmountcore offers these extras (optional dependencies):

 - full, bzip2, gzip, rar, xz, zip, zstd

Full includes all dependencies of the other extras.
The `zip` extra is currently only a placeholder because the built-in `zipfile` module is being used.

In order to install one of these extract, append them in brackets:

```bash
python3 -m pip install --user ratarmount[bzip2]
```

If you are installing on a system for which there exists no manylinux wheel, then you'll have to install dependencies required to build from source:

```bash
sudo apt install python3 python3-pip fuse build-essential software-properties-common zlib1g-dev libzstd-dev liblzma-dev
```


# Usage

This library offers an interface which is sufficient to work with FUSE.
This `MountSource` interface has methods for listing paths and getting file metadata and contents.

The ratarmountcore library offers multiple implementations of `MountSource` for different archive formats:

 - `SQLiteIndexedTar`:
    This is the oldest and most powerful implementation.
    It supports fast access to files inside (compressed) TARs.
 - `RarMountSource`: An implementation for RARs using rarfile.
 - `ZipMountSource`: An implementation for ZIPs using zipfile.
 - `FolderMountSource`: An implementation taking an existing folder as input.

There also are these functional implementations of `MountSource`:

 - `UnionMountSource`: Takes multiple MountSource implementations and shows a merged view of their file hierarchy.
 - `FileVersionLayer`:
    Takes a MountSource as input, decodes the requested paths, also accepting `<file>.version/<number>` paths,
    and calls the methods of the `MountSource` with the given file version.
 - `AutoMountLayer`:
    Takes one `MountSource`, goes over all its files and mounts archives recursively in a similar manner to `UnionMountSource`.

The factory function `open` opens one of the archive `MountSource` implementations according to the file type.

[![Mount Source Class Diagram](doc/MountSource.png)](doc/MountSource.svg)


## Example

```Python3
from ratarmountcore.mountsource.factory import open_mount_source

archive = open_mount_source("foo.tar", recursive=True)
print(archive.list("/"))
info = archive.lookup("/bar")

print("Contents of /bar:")
with archive.open(info) as file:
    print(file.read())
```
