thconfig


Namethconfig JSON
Version 0.9.8 PyPI version JSON
download
home_pagehttps://gitlab.com/tangledlabs/thconfig
SummaryTangledHub Config reader/writter
upload_time2023-04-06 13:45:34
maintainer
docs_urlNone
authorTangledHub
requires_python>=3.10,<4.0
licenseBSD 3-clause
keywords tangled tangledhub tangledlabs thconfig
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build][build-image]]()
[![Status][status-image]][pypi-project-url]
[![Stable Version][stable-ver-image]][pypi-project-url]
[![Coverage][coverage-image]]()
[![Python][python-ver-image]][pypi-project-url]
[![License][bsd3-image]][bsd3-url]


# thconfig

## Overview
TangledHub library for config with a focus on asynchronous functions

## Licensing
thconfig is licensed under the BSD license. Check the [LICENSE](https://opensource.org/licenses/BSD-3-Clause) for details

## Installation
```bash
pip install thconfig
```

---

## Testing
```bash
docker-compose build thconfig-test ; docker-compose run --rm thconfig-test
```

## Building
```bash
docker-compose build thconfig-build ; docker-compose run --rm thconfig-build
```

## Publish
```bash
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
```python
docker-compose build thconfig-test ; docker-compose run --rm thconfig-test
```

## Usage

### File 
Configuration from file 

#### setup
```python
'''
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
```python
'''
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
```python
'''
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
```python
'''
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
```python
'''
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
```python
'''
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
```python
'''
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
```python
'''
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
```python
'''
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()
```

<!-- Links -->

<!-- Badges -->
[bsd3-image]: https://img.shields.io/badge/License-BSD_3--Clause-blue.svg
[bsd3-url]: https://opensource.org/licenses/BSD-3-Clause
[build-image]: https://img.shields.io/badge/build-success-brightgreen
[coverage-image]: https://img.shields.io/badge/Coverage-100%25-green

[pypi-project-url]: https://pypi.org/project/thquickjs/
[stable-ver-image]: https://img.shields.io/pypi/v/thquickjs?label=stable
[python-ver-image]: https://img.shields.io/pypi/pyversions/thquickjs.svg?logo=python&logoColor=FBE072
[status-image]: https://img.shields.io/pypi/status/thquickjs.svg



            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/tangledlabs/thconfig",
    "name": "thconfig",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "tangled,tangledhub,tangledlabs,thconfig",
    "author": "TangledHub",
    "author_email": "info@tangledgroup.com",
    "download_url": "https://files.pythonhosted.org/packages/30/88/beef467d1aa72d8c14cf7c2275e0d44c847b3e4e5577156a6210a0286dfd/thconfig-0.9.8.tar.gz",
    "platform": null,
    "description": "[![Build][build-image]]()\n[![Status][status-image]][pypi-project-url]\n[![Stable Version][stable-ver-image]][pypi-project-url]\n[![Coverage][coverage-image]]()\n[![Python][python-ver-image]][pypi-project-url]\n[![License][bsd3-image]][bsd3-url]\n\n\n# thconfig\n\n## Overview\nTangledHub library for config with a focus on asynchronous functions\n\n## Licensing\nthconfig is licensed under the BSD license. Check the [LICENSE](https://opensource.org/licenses/BSD-3-Clause) for details\n\n## Installation\n```bash\npip install thconfig\n```\n\n---\n\n## Testing\n```bash\ndocker-compose build thconfig-test ; docker-compose run --rm thconfig-test\n```\n\n## Building\n```bash\ndocker-compose build thconfig-build ; docker-compose run --rm thconfig-build\n```\n\n## Publish\n```bash\ndocker-compose build thconfig-publish ; docker-compose run --rm -e PYPI_USERNAME=__token__ -e PYPI_PASSWORD=__SECRET__ thconfig-publish\n```\n\n\n## THCONFIG supported in this library\n...\n\n## Testing\n```python\ndocker-compose build thconfig-test ; docker-compose run --rm thconfig-test\n```\n\n## Usage\n\n### File \nConfiguration from file \n\n#### setup\n```python\n'''\nA class to handle reading and writing configuration data from file\n'''\n\n# you need to provide file with data { configuration }\nconfig_path = 'example_1.json'\n\n# create instance of FileConfig\nconfig = FileConfig(config_path)\n```\n\n#### fetch\n```python\n'''\nReads config data from file\n'''\n\n# you need to provide file with data { configuration }\nconfig_path = 'example_1.json'\n\n# create instance of FileConfig\nconfig = FileConfig(config_path)\n\n# load data from configuration file if success\nres: bool = (await config.fetch()).unwrap()\n```\n\n#### commit\n```python\n'''\nWrite config data to file\n'''\n\n# you need to provide file with data { configuration }\nconfig_path = 'example_1.json'\n\n# create instance of FileConfig\nconfig = FileConfig(config_path)\n\n# set title\nconfig['title'] = 'Config Example'\n\nconfig.title2 = 'Config Example'\n\n# this function change title in file\n(await config.commit()).unwrap()\n```\n\n### CouchConfig \nConfiguration from couchdb \n\n#### setup\n```python\n'''\nA class to handle reading and writing configuration data from couchdb\n\ninstantiate CouchConfig:\n        parameters:\n            uri: str\n'''\n\n# this is url for couchdb where are configuration data \nURI = 'http://tangledhub:tangledhub@couchdb-test:5984/thconfig-test/test_couch_config'\n\n# create intance CouchConfig and set URI property\nconfig = CouchConfig(URI)\n```\n\n#### fetch\nFetching configuration document from couchdb\n```python\n'''\nFetching document and store data in self._state\nSync couchdb -> self._state\nhttps://docs.couchdb.org/en/stable/api/document/common.html#get--db-docid\n\nFetch:\n    parameters:\n        self: CouchConfig\n'''\n\n# this is url for couchdb where are configuration data \nURI = 'http://tangledhub:tangledhub@couchdb-test:5984/thconfig-test/test_couch_config'\n\n# create intance CouchConfig and set URI property\nconfig = CouchConfig(URI)\n\n# fetching data from database\nfetched_data = (await config.fetch()).unwrap()\n```\n\n#### commit\nCommit changes in configuration data in documment in couchdb\n```python\n'''\nCommit document, save data from self._state to couchdb\nSync self._state -> couchdb\nhttps://docs.couchdb.org/en/stable/api/document/common.html#put--db-docid\n\nCommit:\n    parameters:\n        self: CouchConfig\n'''\n\n# this is url for couchdb where are configuration data \nURI = 'http://tangledhub:tangledhub@couchdb-test:5984/thconfig-test/test_couch_config_commit_changes'\n\n# create intance CouchConfig and set URI property\nconfig = CouchConfig(URI)\n\ntitle = 'Couch Config Example'\ndatabase = {'server': '192.168.1.1'}\n\n# set title and database\nconfig['title'] = title\nconfig['database'] = database\n\n# commit\ncommit_0 = (await config.commit()).unwrap()\n```\n\n### EtcdConfig \nConfiguration from EtcdConfig \n\n#### setup\n```python\n'''\nA class to handle reading and writing configuration data from etcd\ninstantiate EtcdConfig:\n    parameters:\n        HOST: str\n        PORT: int\n'''\n\n# you need to provide host and port\nHOST = 'etcd-test'\nPORT = 2379\n\n# create instance of EtcdConfig\nconfig = EtcdConfig(host = HOST, port = PORT)\n```\n\n#### fetch\nFetching configuration document from etcd\n```python\n'''\nFetching document and store data in self._state\nSync etcd -> self._state\nhttps://aetcd3.readthedocs.io/en/latest/reference/client.html#aetcd3.client.Etcd3Client.get_all\n\nFetch:\n    parameters:\n        self: EtcdConfig\n'''\n\n# you need to provide host and port\nHOST = 'etcd-test'\nPORT = 2379\n\n# create instance of EtcdConfig\nconfig = EtcdConfig(host = HOST, port = PORT)\n\n# fetching data from etcd\nfetched_data = (await config.fetch()).unwrap()\n```\n\n#### commit\nCommit changes in configuration data to etcd\n```python\n'''\nCommit document, save data from self._state to etcd\nSync self._state -> etcd\nhttps://aetcd3.readthedocs.io/en/latest/reference/client.html#aetcd3.client.Etcd3Client.put\n\ncommit changes:\n    parameters:\n        self: EtcdConfig\n'''\n\n# you need to provide host and port\nHOST = 'etcd-test'\nPORT = 2379\n\n# create instance of EtcdConfig\nconfig = EtcdConfig(host = HOST, port = PORT)\n\ntitle = 'Couch Config Example'\ndatabase = {'server': '192.168.1.1'}\n\n# set title and database\nconfig['title'] = title\nconfig['database'] = database\n\n# commit\ncommit_0 = (await config.commit()).unwrap()\n```\n\n<!-- Links -->\n\n<!-- Badges -->\n[bsd3-image]: https://img.shields.io/badge/License-BSD_3--Clause-blue.svg\n[bsd3-url]: https://opensource.org/licenses/BSD-3-Clause\n[build-image]: https://img.shields.io/badge/build-success-brightgreen\n[coverage-image]: https://img.shields.io/badge/Coverage-100%25-green\n\n[pypi-project-url]: https://pypi.org/project/thquickjs/\n[stable-ver-image]: https://img.shields.io/pypi/v/thquickjs?label=stable\n[python-ver-image]: https://img.shields.io/pypi/pyversions/thquickjs.svg?logo=python&logoColor=FBE072\n[status-image]: https://img.shields.io/pypi/status/thquickjs.svg\n\n\n",
    "bugtrack_url": null,
    "license": "BSD 3-clause",
    "summary": "TangledHub Config reader/writter",
    "version": "0.9.8",
    "split_keywords": [
        "tangled",
        "tangledhub",
        "tangledlabs",
        "thconfig"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ba66b4eba5ea984b4d93d39f9955e46d3c4281f73d3a7738c6fa110174f0398f",
                "md5": "a29396038cdcbd61494abd39722ac19e",
                "sha256": "5494b156a88f692a44e844b85c12e841f55610bd5067e0078fffe29bc7d0a49b"
            },
            "downloads": -1,
            "filename": "thconfig-0.9.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a29396038cdcbd61494abd39722ac19e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 8652,
            "upload_time": "2023-04-06T13:45:32",
            "upload_time_iso_8601": "2023-04-06T13:45:32.918488Z",
            "url": "https://files.pythonhosted.org/packages/ba/66/b4eba5ea984b4d93d39f9955e46d3c4281f73d3a7738c6fa110174f0398f/thconfig-0.9.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3088beef467d1aa72d8c14cf7c2275e0d44c847b3e4e5577156a6210a0286dfd",
                "md5": "ff60d5fd890e435d35e5a49605129953",
                "sha256": "ab4316808c065dfd6b11d778b936c6b866b86add9aa60bcbb4da7af1fac51653"
            },
            "downloads": -1,
            "filename": "thconfig-0.9.8.tar.gz",
            "has_sig": false,
            "md5_digest": "ff60d5fd890e435d35e5a49605129953",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 7283,
            "upload_time": "2023-04-06T13:45:34",
            "upload_time_iso_8601": "2023-04-06T13:45:34.693711Z",
            "url": "https://files.pythonhosted.org/packages/30/88/beef467d1aa72d8c14cf7c2275e0d44c847b3e4e5577156a6210a0286dfd/thconfig-0.9.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-06 13:45:34",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "gitlab_user": "tangledlabs",
    "gitlab_project": "thconfig",
    "lcname": "thconfig"
}
        
Elapsed time: 0.20161s