FilesFF - Files For Fun
- python package to work with file handles
- use handles of files as parameters without keeping open files
- replace file handles easily with mocks
- handle many file types with generic protocol
to install with all extras
pip install filesff[protobug,ujson,cap,msgpack,s3]
Usage
read a json from gzip compressed file:
accessor = GzippedFileHandle.of_str("./file.gz").access(JsonFormatter())
accessor.dump({"json": "data"})
write a protobuf into a temp file
pip install fileff[protobuf]
from google.protobuf.timestamp_pb2 import Timestamp
accessor = PathFileHandle.of_temp().access(ProtoBytesFileFormatter)
now = Timestamp()
now.FromDatetime(datetime.now())
accessor.dump(now)
loaded_now = accessor.load(message_cls=Timestamp)
implement new file format:
class NewFileFormatter(FullTextFileFormatter):
def load(self, reader: IO, **_) -> AnyStr:
return reader.read().replace("a", "e")
def dump(self, writer: IO, value: Any, **_):
writer.write(value.replace("e", "a"))
use it
file_accessor = PathFileHandle.of_str("./path.ae").access(NewFileFormatter())
file_accessor.dump("ababab")
Metadata
Release files for filesff 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| filesff-0.0.7.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| filesff-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.0 kB
Release files / filesff-0.0.7.tar.gz
| Download URL | filesff-0.0.7.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a10b565001f8b19068be882278b8408e9f4bf7b21064f5ca02b21c12186a7353
|
|
BLAKE2b-256 checksum How to use checksums |
e192090747e05527f2111b132727a0a751b3e885f4b43bc0f2c08402d8c89dd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.11.1 Windows/10
|
Release files / filesff-0.0.7-py3-none-any.whl
| Download URL | filesff-0.0.7-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
357441809bea2bb0e9088028f72871723a46090efde55fa72c44631d0f265189
|
|
BLAKE2b-256 checksum How to use checksums |
53002e48f1ce44c1bf21ca7c1a72a8e2b5716ca3b3b03cea12a01f4cb92ec5bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.11.1 Windows/10
|