Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PyFilesystem

PyFilesystem is an abstraction layer for filesystems. In the same way that Python’s file-like objects provide a common way of accessing files, PyFilesystem provides a common way of accessing entire filesystems. You can write platform-independent code to work with local files, that also works with any of the supported filesystems (zip, ftp, S3 etc.).

Pyfilesystem works with Linux, Windows and Mac.

Supported Filesystems

Here are a few of the filesystems that can be accessed with Pyfilesystem:

  • DavFS access files & directories on a WebDAV server

  • FTPFS access files & directories on an FTP server

  • MemoryFS access files & directories stored in memory (non-permanent but very fast)

  • MountFS creates a virtual directory structure built from other filesystems

  • MultiFS a virtual filesystem that combines a list of filesystems into one, and checks them in order when opening files

  • OSFS the native filesystem

  • SFTPFS access files & directories stored on a Secure FTP server

  • S3FS access files & directories stored on Amazon S3 storage

  • TahoeLAFS access files & directories stored on a Tahoe distributed filesystem

  • ZipFS access files and directories contained in a zip file

Example

The following snippet prints the total number of bytes contained in all your Python files in C:/projects (including sub-directories):

from fs.osfs import OSFS
projects_fs = OSFS('C:/projects')
print sum(projects_fs.getsize(path)
          for path in projects_fs.walkfiles(wildcard="*.py"))

That is, assuming you are on Windows and have a directory called ‘projects’ in your C drive. If you are on Linux / Mac, you might replace the second line with something like:

projects_fs = OSFS('~/projects')

If you later want to display the total size of Python files stored in a zip file, you could make the following change to the first two lines:

from fs.zipfs import ZipFS
projects_fs = ZipFS('source.zip')

In fact, you could use any of the supported filesystems above, and the code would continue to work as before.

An alternative to explicitly importing the filesystem class you want, is to use an FS opener which opens a filesystem from a URL-like syntax:

from fs.opener import fsopendir
projects_fs = fsopendir('C:/projects')

You could change C:/projects to zip://source.zip to open the zip file, or even ftp://ftp.example.org/code/projects/ to sum up the bytes of Python stored on an ftp server.

Documentation

http://docs.pyfilesystem.org

Screencast

This is from an early version of PyFilesystem, but still relevant

http://vimeo.com/12680842

Discussion Group

http://groups.google.com/group/pyfilesystem-discussion

Further Information

http://www.willmcgugan.com/tag/fs/

Metadata

Release files for fs 0.5.5a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fs 0.5.5a1
File Size Uploaded Provenance Actions
fs-0.5.5a1.tar.gz 230.5 kB Without provenance Details for fs-0.5.5a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fs 0.5.5a1
File Interpreter ABI Platform Actions
fs-0.5.5a1-py2-none-any.whl Python 2 none any Details for fs-0.5.5a1-py2-none-any.whl

Total release size: 513.8 kB

Release files / fs-0.5.5a1.tar.gz

Download URL fs-0.5.5a1.tar.gz
Size 230.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f99287c3205441a0c8cc46d3b7bf9da27372fa40f1dc98dcb86af4b8f888f92c
BLAKE2b-256 checksum
How to use checksums
1f9dff1f96fa926c04b6692dbb34c4d0bdc123d29122d5ff52f377d456684cca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fs-0.5.5a1-py2-none-any.whl

Download URL fs-0.5.5a1-py2-none-any.whl
Size 283.3 kB
Tags Python 2
SHA-256 checksum
How to use checksums
29c9ca52a81181c4edb0d0376cd8a74b6ee5ce64bc48a7f8bb62e661563a619a
BLAKE2b-256 checksum
How to use checksums
7ef6cb4ba4e7ef3d8e42dfe149cf0f91e0672eac1aac251a49e32647a4f5fd7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for fs 0.5.5a1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page