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.6.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.6.0
File Size Uploaded Provenance Actions
filefox-0.6.0.tar.gz 5.0 kB Without provenance Details for filefox-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for filefox 0.6.0
File Interpreter ABI Platform Actions
filefox-0.6.0-py3-none-any.whl Python 3 none any Details for filefox-0.6.0-py3-none-any.whl

Total release size: 8.7 kB

Release files / filefox-0.6.0.tar.gz

Download URL filefox-0.6.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4fbfa37204c4530cf6a85dda63a777f967482b4fd9d2ae5bfda8487819259064
BLAKE2b-256 checksum
How to use checksums
41579c23247eda54f787a5f4dea055b3507921dd489d5c330cc814577bd54b0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release files / filefox-0.6.0-py3-none-any.whl

Download URL filefox-0.6.0-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4eea137c605ed1a3a5823d035a45c1404647b53e8ed4d030835464807203a35
BLAKE2b-256 checksum
How to use checksums
e432c3e8b4fa5394ce808aae54cdc80b802b77a677b904f25867bcced4458918
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Security for filefox 0.6.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.

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