No project description provided
Project description
HOTMARKUP
Synchronize data structure with markup file
Currently supported formats: YAML, JSON, Pickle
Main features:
- Work with Connection object as usual data structure. You can use features like array slices or methods of
dict
andlist
- JS-like accessing (foo.bar.buzz instead of foo['bar']['buzz'])
- Modifications logging via
logging
module. Example below - Reload on file change (pass
reload=False
to connection constructor to disable) - Dump file on every change (pass
dump=False
to connection constructor to disable) - Immutable connections (pass
mutable=False
to connection constructor to enable)
Installation
pip install hotmarkup
Examples
Reload
from hotmarkup import JsonConnection
connection = JsonConnection('example.json', default={'changed': False})
print(connection.changed) # Out: False
with open('example.json', 'w') as f:
f.write('{"changed": true}')
print(connection.changed) # Out: True
Dump
from hotmarkup import JsonConnection
connection = JsonConnection('example.json', default={'changed': False})
print(open('example.json').read()) # Out: {"changed": false}
connection.changed = True
print(open('example.json').read()) # Out: {"changed": true}
Logging
import logging
from hotmarkup import YamlConnection
logging.basicConfig(level=logging.INFO)
connection = YamlConnection('example.yaml', default={'something_important': 'old_value'})
connection.something_important = 'new_value'
Output:
INFO:example.yaml:Loaded example.yaml config: {'something_important': 'old_value'}
INFO:example.yaml:Setting 'something_important' to 'new_value'
Counter
from hotmarkup import YamlConnection
connection = YamlConnection('counter.yaml', default={'counter': 0})
connection.counter += 1
print(f'You run this program {connection.counter} times')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hotmarkup-0.1.5.tar.gz
(6.0 kB
view hashes)
Built Distribution
Close
Hashes for hotmarkup-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f9a888560a1c0feca4f2bfec47c79d72528c8864a8c9ea85002bba2f27c3463 |
|
MD5 | 362a6116d1c733a4d907a5f938095dee |
|
BLAKE2b-256 | c44aafc33607d8365b77e925d35244926dfc3877c01df25a825c994b5c826c37 |