PyFilesystem2 is a Python library that provides a common, high-level abstraction layer for interacting with various filesystems, including local, memory, zip, FTP, and more. It enables consistent management of files and directories across different storage backends. The current version is 2.4.16, with frequent maintenance and minor feature releases.
pip install fsVerified import paths — ran on the pinned version, not inferred.
Demonstrates opening and interacting with a memory filesystem and a local OS filesystem. It shows creating, writing, reading, listing, and cleaning up resources, emphasizing the use of context managers for proper resource handling.
Code written for `pyfilesystem` (v1) is incompatible with `fs` (v2). You must rewrite your code to use the `fs` (v2) API and import paths (e.g., `from fs import open_fs` instead of `from fs.opener import open_fs`). The `fs` package on PyPI refers to v2.
Always use filesystem objects within a `with` statement (e.g., `with open_fs('osfs://') as my_fs:`). This ensures resources (like file handles or network connections) are released automatically. If not using a context manager, call `my_fs.close()` explicitly when done.Always use `/` as the path separator when interacting with `fs` objects. Avoid using `os.sep` or platform-specific separators directly within `fs` methods. The `fs.path` module provides utility functions for path manipulation that are consistent with `fs` conventions.
Ensure the filesystem is opened with write permissions if you intend to modify it. `fs.open_fs` has a `writable` parameter, and some filesystems (e.g., `ZipFS` opened in read mode) are inherently read-only. Check `my_fs.is_writable` before attempting writes. For creating read-only views of a writable FS, use `fs.wrap.read_only`.
Ensure `setuptools` is installed in your Python environment (e.g., by adding `setuptools` to your `requirements.txt` or explicitly installing it via `pip install setuptools`).
No dependency data recorded yet.