Cyra is a simple config framework for Python.
Cyra’s ConfigBuilder makes it easy to specify your configuration. The config can be read from and written to a toml file.
If the config file does not exist, Cyra will generate a new one populated with initial values and annotated with helpful comments.
For a more detailed documentation, refer to https://cyra.rtfd.io
Features
Config builder
Value fields (string, int, bool, list, dict)
Value verification
Infinite nesting
Comments
Load/generate config from file
Write config back to file
Sphinx Autodoc
How to use
import cyra
class MyConfig(cyra.Config):
builder = cyra.ConfigBuilder()
builder.comment('Cyra says hello')
msg = builder.define('msg', 'Hello World')
builder.comment('SQL Database settings')
builder.push('DATABASE')
builder.comment('DB server address')
server = builder.define('server', '192.168.1.1')
builder.comment('SQL port (default: 1443)')
port = builder.define('port', 1443)
builder.comment('Credentials')
user = builder.define('username', 'admin')
pwd = builder.define('password', 'my_secret_password')
builder.comment('DB connection enabled')
dben = builder.define('enabled', True)
builder.pop()
How to access your config values:
>>> cfg = MyConfig('config.toml')
>>> cfg.load_file()
>>> cfg.msg
'Hello World'
>>> cfg.msg = 'Bye bye World'
>>> cfg.save_file()
True
Here is the resulting config file:
msg = "Hello World" # Cyra says hello
[DATABASE] # SQL Database settings
server = "192.168.1.1" # DB server address
port = 1443 # SQL port (default: 1443)
username = "admin" # Credentials
password = "my_secret_password"
enabled = true # DB connection enabled
Release files for Cyra 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Cyra-1.0.2.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Cyra-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:16.8 kB
Release files / Cyra-1.0.2.tar.gz
| Download URL | Cyra-1.0.2.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7aece71c9b44ad70428d661d7286dd9b3c2b7de6716d74a591f26a40c9973fa
|
|
BLAKE2b-256 checksum How to use checksums |
8a96a1a87ddcdfcfb970e413c17b4ef0863284d336a538a5fe1f7633d7d22109
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11
|
Release files / Cyra-1.0.2-py3-none-any.whl
| Download URL | Cyra-1.0.2-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
95f5056b16da357b9f41730771d6d4d7418ea2b16e5c3a5330dfa72ed44f1508
|
|
BLAKE2b-256 checksum How to use checksums |
37cce9fe7eb4d7baf2c4d17af69b3849dae4c97d1ba41200d088274a9ae16384
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11
|