Skip to content

uadson/zeconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZeConfig EN - BR

Buid Tests Release

ZeConfig

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.

Features

  • 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.

Installation

pip install zeconfig

How to Use

1. Create a Configuration File

In 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"

2. Initialize ZeConfig

In your Python code, just import config from the ze library.

from ze import config

3. Access Your Settings

Retrieve 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.db

Error Handling

ZeConfig 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.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request on the GitHub repository.

About

Configuration Manager Package

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages