Skip to main content

get-settings is a python library designed to facilitate the retrieval of configuration variables from a settings.py file.

Project description

get-settings

PyPI version

get-settings is a python library designed to facilitate the retrieval of configuration variables from a settings.py file. It provides a convenient way to load these variables as a Python dictionary. This library is particularly useful in the development of Python libraries, as it can dynamically detect and load configuration file content.

Installation

pip install get-settings

Usage

from get_settings import load_settings()

settings = load_settings()  # settings = {"USER": "foo", "EMAIL": "foo@example.org"}

Ensure that settings.py file exists in the project root and contains the necessary configuration parameters

.
├── settings.py
└── foo.py

Don't forget to add get_settings to your pyproject.toml:

dependencies = [
    "get-settings>=0.1.1",
]

Manual configuration

Also, you can manually provide the file path to the library's configuration function:

# Provide the path to the settings.py file
settings_path = "/path/to/settings.py"
settings = load_settings(settings_path)

File format

Varibales accepts from the library

# settings.py

USER = "FOO" # YES
PORT = 8000 # YES
DEBUG = True # YES
ORIGINS = ["http://localhost", ...] # YES
FOO = {"email": "foo@example.com"} # YES

foo = "user" # NO
__FOO__ = "user" # NO

the result of load_settings() will be the following:

{
    "USER": "FOO",
    "PORT": 8000,
    "DEBUG": True,
    "ORIGINS": ["http://localhost", ...],
    "FOO": {"email": "foo@example.com"},
}

Contributing

We welcome contributions to this project! If you would like to contribute, please fork this repository and submit a pull request with your changes. Before submitting a pull request, please make sure that your changes are fully tested and that they adhere to our code standards.

License

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

Credits

Some features in this library are partially inspired by the python-dotenv library Copyright (c) 2014, Saurabh Kumar, 2013, Ted Tieken, 2013, Jacob Kaplan-Moss


Thank you for using get-settings library!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

get_settings-0.1.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

get_settings-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file get_settings-0.1.1.tar.gz.

File metadata

  • Download URL: get_settings-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.8.10 Windows/10

File hashes

Hashes for get_settings-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a6d9b1b04039636fd4ef45872cbaa0ca65f8258e0fac5689de18f4043cb85d61
MD5 67bddc2b5f154ec849cbb5e027cf0822
BLAKE2b-256 bd0f9701671167886f48de84fdc38698ee27f1635332260294cf43e18d35bda0

See more details on using hashes here.

File details

Details for the file get_settings-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: get_settings-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.8.10 Windows/10

File hashes

Hashes for get_settings-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b87d15635c09c48a2bc9a16219cfb3abdde00d54e82504f1d55de4cfd0a57ac2
MD5 93e7cdab7d9ea44fc2500be821f2241c
BLAKE2b-256 5764f47f0670ab5c52b48e7b2294067905080bb82e4db9e62bf6e6c620d30bf1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page