https://github.com/ebsaral/filewriter
An easy debugger which prints into files, but can be used multi functional for production as well. It can also read. JSON supported. In case you ever need.
https://github.com/ebsaral/filewriter
file json open python reader writer
Last synced: about 2 months ago
JSON representation
An easy debugger which prints into files, but can be used multi functional for production as well. It can also read. JSON supported. In case you ever need.
- Host: GitHub
- URL: https://github.com/ebsaral/filewriter
- Owner: ebsaral
- License: bsd-3-clause
- Created: 2019-06-07T21:26:03.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-18T09:44:56.000Z (about 7 years ago)
- Last Synced: 2025-09-25T04:47:48.110Z (10 months ago)
- Topics: file, json, open, python, reader, writer
- Language: Python
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# filewriter 2.0.2
[](https://circleci.com/gh/ebsaral/filewriter)
[](https://codecov.io/gh/ebsaral/filewriter)
Hello.
I am an easy debugger which prints into files, but can be used multi functional for production as well. I can also read. In case you need me ever.
Simplicity within a certain complexity.
# Install
`pip install filewriter`
# Documentation
## param: filename
Name of the file. The extension `.log` will be added.
Default: `debug`
ENV name: `READABLE_GLOBAL_VARIABLE_NAME`
## param: debug
If set True, prints what's going on.
Default: True
## param: json
If set True, it will enable json conversion
Default: True
## param: callback
If set (a function), the function gets executed with the path of created file.
Default: None
## Examples
```python
from filewriter import Writer, Reader, Reverse
# creates a file called debug.log and saves into
Writer() << {'allah': 'birdir'}
>>> {"allah": "birdir"}
# reverse the operator, if that's easier to read
# https://docs.python.org/3/reference/simple_stmts.html#assignment-statements
Reverse({'allah': 'birdir'}) >> Writer()
>>> {"allah": "birdir"}
# reads from debug.log
test = Reader().data
print(test)
>>> {'allah': 'birdir'}
# delete callback
import os
Writer(callback: lambda filename: os.remove(filename)) >> {'test': 'callback'} # deletes the file
```
# API
## filewriter.Writer
```python
Writer(
filename="debug",
debug=True,
json=True,
ext="log",
callback=None,
)
```
## filewriter.Reader
```python
Reader(
filename="debug",
debug=True,
ext="log",
json=True,
)
```
### filewriter.Reader().data
Set from file after the initialization
----
Twitter: @ebsaral