Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Build Status Stable Version Coverage Python License

thconfig

Overview

TangledHub library for config with a focus on asynchronous functions

Licensing

thconfig is licensed under the BSD license. Check the LICENSE for details

Installation

pip install thconfig

Testing

docker-compose build thconfig-test ; docker-compose run --rm thconfig-test

Building

docker-compose build thconfig-build ; docker-compose run --rm thconfig-build

Publish

docker-compose build thconfig-publish ; docker-compose run --rm -e PYPI_USERNAME=__token__ -e PYPI_PASSWORD=__SECRET__ thconfig-publish

THCONFIG supported in this library

...

Testing

docker-compose build thconfig-test ; docker-compose run --rm thconfig-test

Usage

File

Configuration from file

setup

'''
A class to handle reading and writing configuration data from file
'''

# you need to provide file with data { configuration }
config_path = 'example_1.json'

# create instance of FileConfig
config = FileConfig(config_path)

fetch

'''
Reads config data from file
'''

# you need to provide file with data { configuration }
config_path = 'example_1.json'

# create instance of FileConfig
config = FileConfig(config_path)

# load data from configuration file if success
res: bool = (await config.fetch()).unwrap()

commit

'''
Write config data to file
'''

# you need to provide file with data { configuration }
config_path = 'example_1.json'

# create instance of FileConfig
config = FileConfig(config_path)

# set title
config['title'] = 'Config Example'

config.title2 = 'Config Example'

# this function change title in file
(await config.commit()).unwrap()

CouchConfig

Configuration from couchdb

setup

'''
A class to handle reading and writing configuration data from couchdb

instantiate CouchConfig:
        parameters:
            uri: str
'''

# this is url for couchdb where are configuration data 
URI = 'http://tangledhub:tangledhub@couchdb-test:5984/thconfig-test/test_couch_config'

# create intance CouchConfig and set URI property
config = CouchConfig(URI)

fetch

Fetching configuration document from couchdb

'''
Fetching document and store data in self._state
Sync couchdb -> self._state
https://docs.couchdb.org/en/stable/api/document/common.html#get--db-docid

Fetch:
    parameters:
        self: CouchConfig
'''

# this is url for couchdb where are configuration data 
URI = 'http://tangledhub:tangledhub@couchdb-test:5984/thconfig-test/test_couch_config'

# create intance CouchConfig and set URI property
config = CouchConfig(URI)

# fetching data from database
fetched_data = (await config.fetch()).unwrap()

commit

Commit changes in configuration data in documment in couchdb

'''
Commit document, save data from self._state to couchdb
Sync self._state -> couchdb
https://docs.couchdb.org/en/stable/api/document/common.html#put--db-docid

Commit:
    parameters:
        self: CouchConfig
'''

# this is url for couchdb where are configuration data 
URI = 'http://tangledhub:tangledhub@couchdb-test:5984/thconfig-test/test_couch_config_commit_changes'

# create intance CouchConfig and set URI property
config = CouchConfig(URI)

title = 'Couch Config Example'
database = {'server': '192.168.1.1'}

# set title and database
config['title'] = title
config['database'] = database

# commit
commit_0 = (await config.commit()).unwrap()

EtcdConfig

Configuration from EtcdConfig

setup

'''
A class to handle reading and writing configuration data from etcd
instantiate EtcdConfig:
    parameters:
        HOST: str
        PORT: int
'''

# you need to provide host and port
HOST = 'etcd-test'
PORT = 2379

# create instance of EtcdConfig
config = EtcdConfig(host = HOST, port = PORT)

fetch

Fetching configuration document from etcd

'''
Fetching document and store data in self._state
Sync etcd -> self._state
https://aetcd3.readthedocs.io/en/latest/reference/client.html#aetcd3.client.Etcd3Client.get_all

Fetch:
    parameters:
        self: EtcdConfig
'''

# you need to provide host and port
HOST = 'etcd-test'
PORT = 2379

# create instance of EtcdConfig
config = EtcdConfig(host = HOST, port = PORT)

# fetching data from etcd
fetched_data = (await config.fetch()).unwrap()

commit

Commit changes in configuration data to etcd

'''
Commit document, save data from self._state to etcd
Sync self._state -> etcd
https://aetcd3.readthedocs.io/en/latest/reference/client.html#aetcd3.client.Etcd3Client.put

commit changes:
    parameters:
        self: EtcdConfig
'''

# you need to provide host and port
HOST = 'etcd-test'
PORT = 2379

# create instance of EtcdConfig
config = EtcdConfig(host = HOST, port = PORT)

title = 'Couch Config Example'
database = {'server': '192.168.1.1'}

# set title and database
config['title'] = title
config['database'] = database

# commit
commit_0 = (await config.commit()).unwrap()

Metadata

Release files for thconfig 0.9.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thconfig 0.9.8
File Size Uploaded Provenance Actions
thconfig-0.9.8.tar.gz 7.3 kB Without provenance Details for thconfig-0.9.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thconfig 0.9.8
File Interpreter ABI Platform Actions
thconfig-0.9.8-py3-none-any.whl Python 3 none any Details for thconfig-0.9.8-py3-none-any.whl

Total release size: 15.9 kB

Release files / thconfig-0.9.8.tar.gz

Download URL thconfig-0.9.8.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ab4316808c065dfd6b11d778b936c6b866b86add9aa60bcbb4da7af1fac51653
BLAKE2b-256 checksum
How to use checksums
3088beef467d1aa72d8c14cf7c2275e0d44c847b3e4e5577156a6210a0286dfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.3 Linux/5.4.109+

Release files / thconfig-0.9.8-py3-none-any.whl

Download URL thconfig-0.9.8-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5494b156a88f692a44e844b85c12e841f55610bd5067e0078fffe29bc7d0a49b
BLAKE2b-256 checksum
How to use checksums
ba66b4eba5ea984b4d93d39f9955e46d3c4281f73d3a7738c6fa110174f0398f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.3 Linux/5.4.109+

Security for thconfig 0.9.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page