confoid-0.2.0
توضیحات
Configuration Management for Python.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX :: Linux |
| نام فایل | confoid-0.2.0 |
| نام | confoid |
| نسخه کتابخانه | 0.2.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Savio Fernandes |
| ایمیل نویسنده | savio@saviof.com |
| آدرس صفحه اصلی | https://github.com/saviof-hub/confoid |
| آدرس اینترنتی | https://pypi.org/project/confoid/ |
| مجوز | - |
# Confoid
Configuration Management for Python.
[](https://pypi.org/project/confoid/)
[](https://pypi.org/project/confoid/)
[](https://github.com/saviof-hub/confoid/blob/main/LICENSE)
[](https://github.com/artbycrunk/hyper-prompt)
[](https://isitmaintained.com/project/saviof-hub/confoid "Average time to resolve an issue")
[](https://isitmaintained.com/project/saviof-hub/confoid "Percentage of issues still open")
## Install
```bash
$ pip install confoid
```
## Loading a single config file
```py
import confoid
new_settings = confoid.Config("application.yml")
```
## Loading multiple config file
Multiple files can be provided in `order` and will merge with the previous configuration.
```py
import confoid
config_files = ["application.yml", "application.development.yml"]
new_settings = confoid.Config(
config_files,
base_dir="config",
)
```
## Autoload based on provided environment
```py
import confoid
new_settings = confoid.Config("application.yml", current_env="development")
# this will load application.yml and application.{current_env}.yml
```
## Reading the settings
```py
settings.username == "admin" # dot notation with multi nesting support
settings['password'] == "secret123" # dict like access
settings.get("nonexisting", "default value") # Default values just like a dict
settings.databases.name == "mydb" # Nested key traversing
```
## Config merging
application.yml
```yml
default:
prefix:
otp: "user-otp"
auth: "auth-tokens"
type: inmemory
redis:
url:
```
application.development.yml
```yml
default:
type: redis
redis:
url: redis://saviof.com
encoding: "utf8"
```
Will resolve to the following final config
```yml
default:
prefix:
otp: "user-otp"
auth: "auth-tokens"
type: redis
redis:
url: redis://saviof.com
encoding: "utf8"
```
## Config environment vars
All fields can use environment variables with a fallback default value
```yml
password: ${TEST_SERVICE_DEFAULT_PASSWORD:test}
```
## Validators can be added for pre checks on loaded config
```python
from confoid import Validator
config_files = ["application.yml", "application.development.yml"]
new_settings = confoid.Config(
config_files,
base_dir="config",
validators=[
Validator("default", "default.redis.password", must_exist=True)
Validator("otp.length", gte=6, lte=20)
Validator("default.type", values=["inmemory", "redis"])
]
)
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.* | Python |
نحوه نصب
نصب پکیج whl confoid-0.2.0:
pip install confoid-0.2.0.whl
نصب پکیج tar.gz confoid-0.2.0:
pip install confoid-0.2.0.tar.gz