ZeConfig is a Python library designed to manage application settings, making it easy to handle sensitive data and environment-specific configurations. It supports configuration files in TOM, JSON, YAML, YML, and ENV formats.
- Automatic Detection: Automatically finds the configuration file within the current directory or its subdirectories.
- Multi-format Support: Works seamlessly with TOML, JSON, YAML, YML, and ENV files.
- Simple API: Easy access to keys and values for any environment.
pip install zeconfigIn your project's root directory, create a configuration file. For example, a config.json:
{
"DATABASE_URL": "sqlite:///dev.db",
"SECRET_KEY": "a-very-secret-key"
}Or a .env file:
DATABASE_URL="sqlite:///dev.db"
SECRET_KEY="a-very-secret-key"In your Python code, just import config from the ze library.
from ze import configRetrieve any value by its key. ZeConfig will automatically load it from your configuration file.
DATABASE_URL = config("DATABASE_URL")
SECRET_KEY = config("SECRET_KEY")
print(f"Database URL: {DATABASE_URL}")
>>> OUTPUT:
Database URL: sqlite:///dev.dbZeConfig raises descriptive exceptions for common issues:
FileNotFoundError: If no configuration file is found in the project.KeyError: If a requested key is missing from the configuration file.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Feel free to open an issue or submit a pull request on the GitHub repository.
