fluentfs
The fluentfs library provides a functional and fluent interface for filesystem interactions.
This library is usable and tested, but the API is currently not stable, a lot of features are still missing etc.
In summary - try it out, but (obviously) don't use it for anything in production.
Requirements
You need Python >= 3.9 for this library.
Installation
You can install fluentfs using the pip package manager:
pip install fluentfs
Code examples
Let's say you need to get the total number of lines of all txt files in the current directory (including its subdirectories).
The fluentfs library allows you to express this functionally as following:
- Filter the files by the "txt" extension
- Map the files to their line counts
- Reduce the line counts to their sum
This is how it looks in code:
import fluentfs as fs
total_txt_line_count = (
fs.Dir(".") # get the current directory
.files # get an iterator for the (regular) files in the current directory
.filter_extension("txt") # filter the files by the txt extension
.text_file_iterator() # all the files should now be text files -> obtain a text file iterator to enable text file functions
.map_line_count() # map every file to its line count
.sum() # sum the line count
)
print(total_txt_line_count)
The library is very flexible, allowing you to write both short and long forms for most properties:
import fluentfs as fs
# Short form (for when you quickly need to prototype something)
fs.Dir(".").files.filter_ext("txt").t().map_lc().sum()
# Long form (for when you need to use the library in a codebase)
(
fs.Dir(".")
.files
.filter_extension("txt")
.text_file_iterator()
.map_line_count()
.sum()
)
The fluentfs library is very general.
If you need to perform an operation that is currently not present, simply call the respective higher-order functions with your own callables.
For example here is how we could perform our task by explicitly calling the respective higher-order functions:
import fluentfs as fs
(
fs.Dir(".")
.files
.filter(lambda f: f.extension == "txt")
.text_file_iterator()
.map_self(lambda f: f.line_count)
.reduce(lambda x, y: x + y, 0)
)
Documentation
You can have a look at the basics if this is the first time you are using this library.
You can have a look at the guide if you wish to go more in-depth.
You can have a look at the recipes if you have a specific task you want to accomplish and want to look at some fluent chains that accomplish this or a similar task.
You can also have a look at the API documentation.
Metadata
Release files for fluentfs 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fluentfs-0.4.0.tar.gz | 24.0 kB | Without provenance | Details for fluentfs-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fluentfs-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for fluentfs-0.4.0-py3-none-any.whl |
Total release size: 58.8 kB
Release files / fluentfs-0.4.0.tar.gz
| Download URL | fluentfs-0.4.0.tar.gz |
|---|---|
| Size | 24.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5cdabc9da926061a0ab3b29e79840a91bce444dde5bb0dd6b005f2e8dd99eaa7
|
|
BLAKE2b-256 checksum How to use checksums |
fa0b3b1dbcc04bdb8b001bc5ca11651a877b5cab05077596519d73338efaa60b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Release files / fluentfs-0.4.0-py3-none-any.whl
| Download URL | fluentfs-0.4.0-py3-none-any.whl |
|---|---|
| Size | 34.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
99d4f5dc63c082444e792a603e8ea9d5b06553f86deb1777bf1f09fa49994f1a
|
|
BLAKE2b-256 checksum How to use checksums |
cff43e05fa213f43ca2e2912af3fe05d48f5d905d319d2d201a38e8221e2b841
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for fluentfs 0.4.0
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.