Skip to main content

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_kwargs which is an optional dict will 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)

Source distribution for filefox 0.7.0
File Size Uploaded
filefox-0.7.0.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for filefox 0.7.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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