Currently supported formats: YAML, JSON, Pickle
- Work with Connection object as usual data structure. You can use features like array slices or methods of
dictandlist - JS-like accessing (foo.bar.buzz instead of foo['bar']['buzz'])
- Mutations logging via
loggingmodule. Example below - Reload on file change (pass
reload=Falseto connection constructor to disable) - Update file on every change (pass
save=Falseto connection constructor to disable) - Immutable connections (pass
mutable=Falseto connection constructor to enable)
pip install hotmarkupfrom 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: Truefrom 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}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
from hotmarkup import YamlConnection
connection = YamlConnection('counter.yaml', default={'counter': 0})
connection.counter += 1
print(f'You run this program {connection.counter} times')