filesff-0.0.7
توضیحات
Files for Fun; Python Utilities
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | filesff-0.0.7 |
| نام | filesff |
| نسخه کتابخانه | 0.0.7 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Netanel Revah |
| ایمیل نویسنده | netanelrevah@outlook.com |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/filesff/ |
| مجوز | MIT |
# FilesFF - Files For Fun
[](https://pypi.python.org/pypi/filesff/)
[](https://pypi.python.org/pypi/filesff/)
[](https://pypi.python.org/pypi/filesff/)
[](https://pypi.python.org/pypi/filesff/)
* 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
```shell
pip install filesff[protobug,ujson,cap,msgpack,s3]
```
## Usage
read a json from gzip compressed file:
```python
accessor = GzippedFileHandle.of_str("./file.gz").access(JsonFormatter())
accessor.dump({"json": "data"})
```
write a protobuf into a temp file
```shell
pip install fileff[protobuf]
```
```python
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:
```python
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
```python
file_accessor = PathFileHandle.of_str("./path.ae").access(NewFileFormatter())
file_accessor.dump("ababab")
```
نیازمندی
| مقدار | نام |
|---|---|
| >=5.6.0,<6.0.0 | ujson |
| >=4.22.1,<5.0.0 | protobuf |
| >=0.1.4,<0.2.0 | cap |
| >=1.0.5,<2.0.0 | msgpack |
| >=1.26.91,<2.0.0 | boto3 |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.10,<4.0 | Python |
نحوه نصب
نصب پکیج whl filesff-0.0.7:
pip install filesff-0.0.7.whl
نصب پکیج tar.gz filesff-0.0.7:
pip install filesff-0.0.7.tar.gz