Table of Contents TOC
Introduction
filefox is a simple helper toolbox for reading and writing files.
Installation
From pip
pip install filefox
From source
pip install git+https://github.com/Yevgnen/filefox.git
Usages
Reading/Writing functions
| Function | Description |
|---|---|
read_json |
Reading Json file |
write_json |
Writing Json file |
read_pickle |
Reading Pickle file |
write_pickle |
Writing Pickle file |
read_toml |
Reading Toml file |
write_toml |
Writing Toml file |
read_toml |
Reading text file |
write_toml |
Writing text file |
read |
Detect file extension, decompress when necessary, read file |
write |
Detect file extension, write file, compress when necessary |
These functions have the following convention of their signatures:
reader(filename, ..., file_kwargs=None, ...)
writer(obj, filename, ..., file_kwargs=None, ...)
- For all readers, the first positional argument is always the filename.
- For all writers, the first positional argument is always the dump object and the second is filename.
- All functions accpet a keyword argument
file_kwargswhich is an optionaldictwill be unpacked and passed to file opening function, e.g.open. The other keyword arguments will be passed to internal load/dump functions.
Example
# -*- coding: utf-8 -*-
import filefox
obj = {
"name": "John",
"age": 12,
}
filefox.write_json(obj, "json_data.json")
assert obj == filefox.read_json("json_data.json")
filefox.write_json(obj, "json_data.json.gz")
assert obj == filefox.read_json("json_data.json.gz")
filefox.write(obj, "json_data.json")
assert obj == filefox.read("json_data.json")
filefox.write(obj, "json_data.json.gz")
assert obj == filefox.read("json_data.json.gz")
filefox.write_json(
obj, "json_data.json", file_kwargs={"mode": "w", "encoding": "utf8"}, indent=2
)
assert obj == filefox.read_json("json_data.json", file_kwargs={"encoding": "utf8"})
Contribution
Formatting Code
To ensure the codebase complies with a style guide, please use flake8, black and isort tools to format and check codebase for compliance with PEP8.
Metadata
Release files for filefox 0.7.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 | |
|---|---|---|---|---|
| filefox-0.7.0.tar.gz | 5.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| filefox-0.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / filefox-0.7.0.tar.gz
| Download URL | filefox-0.7.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9dea49ffb100c61464a3c993cf0e5187accc94fa8647e379d9e9f0b3cbd3cb97
|
|
BLAKE2b-256 checksum How to use checksums |
4242d31d553a700139f1184a68c33a54aba5910d85f92d393fd31e0c2cd38dae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Release files / filefox-0.7.0-py3-none-any.whl
| Download URL | filefox-0.7.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d4c83692db3e8293152df311166f4631d0b1b3a1f4c4ee04cf97ebbeb30c7eb
|
|
BLAKE2b-256 checksum How to use checksums |
6f5afe64348fba779db5e71e6acbd63d18b46be8262a2a87b604a017d90bed4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Security for filefox 0.7.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.