Skip to main content

No project description provided

Project description

HOTMARKUP

Build Status

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 and list
  • 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


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 hashes)

Uploaded Source

Built Distribution

hotmarkup-0.1.9-py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page