fs.archive

Pyfilesystem2 for various archive filesystems

MIT License

Downloads
807
Stars
17
Committers
2

fs.archive star me

Requirements

PyFilesystem2 PyPI fs Source fs License fs
six PyPI six Source six License six

fs.archive supports all Python versions supported by PyFilesystem2: Python 2.7, and Python 3.5 onwards. Code should still be compatible with Python 3.4, but is not tested anymore.

Installation

Install directly from PyPI, using pip:

$ pip install fs.archive

Additional features

fs.archive also provides the following extras, allowing you to read from more archive formats:

  • tar.xz: support for xz compressed tar files. Requires the additional
    backports.lzma module
    in Python 2, but is available natively in Python 3.
  • iso: pure-python reading/writing ISO disk images (with support for ISO
    9660 Levels 1, 2 and 3, Joliet and Rock Ridge extensions). Requires
    the pycdlib library.
  • 7z: support for 7z archives. Requires the py7zr
    and iocursor libraries.
  • all: install all of the above.

Usage

Opener

The fs.archive.open_archive function is the easiest way to open an archive filesystem, with an archive located on any other filesystem, directly determining the class to use from the file extension:

>>> from fs import open_fs
>>> from fs.archive import open_archive

>>> my_fs = open_fs(u'temp://')
>>> with open_archive(my_fs, u'test.zip') as archive:
...     type(archive)
<class 'fs.archive.zipfs.ZipFS'>

Constructors

All the filesystems implemented in fs.archive also support reading from (and if not read-only, writing to) a file handle:

>>> import fs.archive.tarfs
>>> with fs.open_fs(u'mem://') as mem:
...     with fs.archive.tarfs.TarFS(mem.openbin(u'test.tar', 'w')) as tar:
...         tar.setbytes(u'hello', b'Hello, World!')
...     with fs.archive.tarfs.TarFS(mem.openbin(u'test.tar', 'r+')) as tar:
...         tar.isfile(u'hello')
True

Feedback

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker of the project if you need to report or ask something. If you are filling in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproductible situation.

Credits

fs.sshfs is developed and maintained by:

The following people contributed to fs.archive:

This project obviously owes a lot to the PyFilesystem2 project and all its contributors.

See also

  • fs, the core
    pyfilesystem2 library
  • fs.sshfs, a SFTP/SSH
    implementation for pyfilesystem2 using
    paramiko
  • fs.smbfs, a SMB
    implementation for pyfilesystem2 using
    pysmb