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'])
- Mutations logging via
logging
module. Example below - Reload on file change (pass
reload=False
to connection constructor to disable) - Update file on every change (pass
save=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:Mutation UPDATE example.yaml.something_important=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.9.tar.gz
(6.3 kB
view details)
Built Distribution
File details
Details for the file hotmarkup-0.1.9.tar.gz
.
File metadata
- Download URL: hotmarkup-0.1.9.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f97b741383feef34c2497934292d38304cb9003408cd56f1d04cfe676301226 |
|
MD5 | 66a749145b9e0f74d3eace5396421164 |
|
BLAKE2b-256 | 6b0cc9faa4a79a65e84e4eb21dde5b87713b3144f880927983f5fa2ca5e69254 |
File details
Details for the file hotmarkup-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: hotmarkup-0.1.9-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 010b536273b4fadb6dcc4d1bcd71e171e35680bbdbca4bf6dc2bdad8a51e5171 |
|
MD5 | b91cd625a9b15b5348f137b452924b68 |
|
BLAKE2b-256 | a812c6d3e2cb1ce7a13a860e0e53f3c77507a344044cbeff8653b40389cde989 |