Package: thconfig
thconfigOverviewTangledHub library for config with a focus on asynchronous functionsLicensingthconfig is licensed under the BSD license. Check theLICENSEfor detailsInstallationpipinstallthconfigTestingdocker-composebuildthconfig-test;docker-composerun--rmthconfig-testBuildingdocker-composebuildthconfig-build;docker-composerun--rmthconfig-buildPublishdocker-composebuildthconfig-publish;docker-composerun--rm-ePYPI_USERNAME=__token__-ePYPI_PASSWORD=__SECRET__thconfig-publishTHCONFIG supported in this library...Testingdocker-composebuildthconfig-test;docker-composerun--rmthconfig-testUsageFileConfiguration from filesetup'''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 FileConfigconfig=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 FileConfigconfig=FileConfig(config_path)# load data from configuration file if successres:bool=(awaitconfig.fetch()).unwrap()commit'''Write config data to file'''# you need to provide file with data { configuration }config_path='example_1.json'# create instance of FileConfigconfig=FileConfig(config_path)# set titleconfig['title']='Config Example'config.title2='Config Example'# this function change title in file(awaitconfig.commit()).unwrap()CouchConfigConfiguration from couchdbsetup'''A class to handle reading and writing configuration data from couchdbinstantiate CouchConfig:parameters:uri: str'''# this is url for couchdb where are configuration dataURI='http://tangledhub:tangledhub@couchdb-test:5984/thconfig-test/test_couch_config'# create intance CouchConfig and set URI propertyconfig=CouchConfig(URI)fetchFetching configuration document from couchdb'''Fetching document and store data in self._stateSync couchdb -> self._statehttps://docs.couchdb.org/en/stable/api/document/common.html#get--db-docidFetch:parameters:self: CouchConfig'''# this is url for couchdb where are configuration dataURI='http://tangledhub:tangledhub@couchdb-test:5984/thconfig-test/test_couch_config'# create intance CouchConfig and set URI propertyconfig=CouchConfig(URI)# fetching data from databasefetched_data=(awaitconfig.fetch()).unwrap()commitCommit changes in configuration data in documment in couchdb'''Commit document, save data from self._state to couchdbSync self._state -> couchdbhttps://docs.couchdb.org/en/stable/api/document/common.html#put--db-docidCommit:parameters:self: CouchConfig'''# this is url for couchdb where are configuration dataURI='http://tangledhub:tangledhub@couchdb-test:5984/thconfig-test/test_couch_config_commit_changes'# create intance CouchConfig and set URI propertyconfig=CouchConfig(URI)title='Couch Config Example'database={'server':'192.168.1.1'}# set title and databaseconfig['title']=titleconfig['database']=database# commitcommit_0=(awaitconfig.commit()).unwrap()EtcdConfigConfiguration from EtcdConfigsetup'''A class to handle reading and writing configuration data from etcdinstantiate EtcdConfig:parameters:HOST: strPORT: int'''# you need to provide host and portHOST='etcd-test'PORT=2379# create instance of EtcdConfigconfig=EtcdConfig(host=HOST,port=PORT)fetchFetching configuration document from etcd'''Fetching document and store data in self._stateSync etcd -> self._statehttps://aetcd3.readthedocs.io/en/latest/reference/client.html#aetcd3.client.Etcd3Client.get_allFetch:parameters:self: EtcdConfig'''# you need to provide host and portHOST='etcd-test'PORT=2379# create instance of EtcdConfigconfig=EtcdConfig(host=HOST,port=PORT)# fetching data from etcdfetched_data=(awaitconfig.fetch()).unwrap()commitCommit changes in configuration data to etcd'''Commit document, save data from self._state to etcdSync self._state -> etcdhttps://aetcd3.readthedocs.io/en/latest/reference/client.html#aetcd3.client.Etcd3Client.putcommit changes:parameters:self: EtcdConfig'''# you need to provide host and portHOST='etcd-test'PORT=2379# create instance of EtcdConfigconfig=EtcdConfig(host=HOST,port=PORT)title='Couch Config Example'database={'server':'192.168.1.1'}# set title and databaseconfig['title']=titleconfig['database']=database# commitcommit_0=(awaitconfig.commit()).unwrap()