autoyaml because config should be easy
Autoconfig is a config generator that takes a dictionary, writes it to a file and loads it back as a dictionary.
The aim of this project is to standardise the way python projects create and feed parameters into python applications without having to rewrite the same IO functions every time.
Installation
pip install autoyaml
Usage
Write your config either from an interactive terminal or from a script
from autoyaml import write_config
conf = {
'parameter1': 1,
'parameter2': 'something'
}
application_name = 'app_name'
write_config(conf,application_name)
Load your config from another python application
from autoyaml import load_config
class My_Class(object):
def __init__(self, **kwargs):
self.parameter1 = kwargs['parameter1']
self.parameter2 = kwargs['parameter2']
self.show_parameters()
def show_parameters(self):
print('parameter1 : {}'.format(self.parameter1))
print('parameter2 : {}'.format(self.parameter2))
if __name__ == "__main__":
my_class = My_Class(**load_config('app_name'))
Password Protected Encryption
from autoyaml import write_config
from getpass import getpass
conf = {
'secret_key': getpass('Secret Key? ')
}
application_name = 'app_name1'
write_config(conf, application_name, encrypted=True)
Loads the same but requires password input by default
from autoyaml import load_config
class My_Class(object):
def __init__(self, **kwargs):
self.secret_key = kwargs['secret_key']
self.show_parameters()
def show_parameters(self):
print('the last character of your secret it {}'.format(self.secret_key[-1]))
if __name__ == "__main__":
my_class = My_Class(**load_config('app_name1'))
Create a custom password function
from autoyaml import load_config, write_config
def BAD_PASSWORD_FUNCTION():
return 'password123'
write_config({'foo':'bar'},'app_name2', encrypted=True, password_function=BAD_PASSWORD_FUNCTION)
print(load_config('app_name3', password_function=BAD_PASSWORD_FUNCTION)
Release files for autoyaml 2021.1.11.1642
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| autoyaml-2021.1.11.1642.tar.gz | 3.6 kB | Details |
Release files / autoyaml-2021.1.11.1642.tar.gz
| Download URL | autoyaml-2021.1.11.1642.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72dfb7f5e2bc103c418a2bce2a0d4d08143084fe1c853334bce35546246a7afe
|
|
BLAKE2b-256 checksum How to use checksums |
4318bc2577587432fd157182c266facddb8cfcd86716f7ef524170931761a4a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.7
|