Lapa commons used for reading the configuration file.
Project description
lapa_commons
About
Lapa commons used for reading the configuration file.
Installation
pip install lapa_commons
Env
- python>=3.12.0
Usage
Create sample config.ini
[ENVIRONMENT]
log_level = INFO
[DATABASE]
Db_Host = localhost
Db_Port = 5432
Db_Name = my_database
Db_User = my_user
Db_Password = my_password
[API]
API_KEY = abcdef1234567890
BASE_URL = https://api.example.com/v1
Sample code
# import lapa_commons
from lapa_commons.main import read_configuration_from_file_path
# call the read_configuration_from_file_path() and provide file path
ldict_configuration = read_configuration_from_file_path('/home/lavsharma/python-project/temp/config.ini')
Output
{'API': {'API_KEY': 'abcdef1234567890', 'BASE_URL': 'https://api.example.com/v1'}, 'DATABASE': {'Db_Host': 'localhost', 'Db_Name': 'my_database', 'Db_Password': 'my_password', 'Db_Port': '5432', 'Db_User': 'my_user'}, 'ENVIRONMENT': {'log_level': 'INFO'}}
Changelog
v0.0.2
- bug fix when reading environment variables.
v0.0.1
- configparser added in the dependency.
- Function read_configuration_from_file_path() added which reads the configuration from a filepath.
- Support for any number of sections in the configuration file.
- Environment section variables will be first checked in the OS, if not found in the OS then it will be read from the configuration file.
- MODULE_NAME added in the init.py
- Errors are raised in the module instead of logging.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lapa_commons-0.0.2.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for lapa_commons-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78dc5a4dacf08d62c48c31edf1ad26d334795f7691ec3a24351e6d8ba2107b6d |
|
MD5 | ae8b70bce01ff19f266bcd008310f10c |
|
BLAKE2b-256 | 96ce6db05dd39bef1d233c35866a57be85760dcd78e84f697e5d5f4be7c66ceb |