Package to read config files
Project description
Python config file reader
Description
TBD
Installation
pip install sat_config_reader
or
python -m pip install sat_config_reader
Usage
tests/mocks/config_1/my_defaults.ini
[DEFAULT]
NAME = localhost
PORT = 8080
LOG_FILE = /tmp/logfile.log
[config1]
PORT = 12345
LOG_FILE = /tmp/config1.log
[config2]
NAME = remote_server
PORT = 80
LOG_FILE = /path/to/file.log
main.py
Without dataclass, result will be a dict[str, dict]
from src.read_config import config_reader
reader = config_reader("./tests/mocks/config_1/my_defaults.ini")
port = reader.get('config1').get('PORT')
assert 12345 == port
print(port)
with dataclass, result is a dict[str, TypeMapping]
from dataclasses import dataclass
from src.read_config import config_reader
@dataclass
class TypeMapping:
NAME: str
PORT: int
LOG_FILE: str
reader = config_reader("./tests/mocks/config_1/my_defaults.ini", TypeMapping)
config1: TypeMapping = reader.get('config1')
port = config1.PORT
assert 12345 == port
print(port)
Example
TBD
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sat_config_reader-0.0.1.tar.gz.
File metadata
- Download URL: sat_config_reader-0.0.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddbf4b59671b8a9922ce3afa0257c325ba7c35f7bab61f222d5d65bb23455220
|
|
| MD5 |
470bf2df43720cdb352b82a6c06fe151
|
|
| BLAKE2b-256 |
9ac6a498929aeabe4766cae677681c0c2ede7bf9961ebaabffe69604571e44b8
|
File details
Details for the file sat_config_reader-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sat_config_reader-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
091ba25f2d789536c2d1659afa0ab45a846ee4da11f6f6772e6903c42646c508
|
|
| MD5 |
fc9505ac0d9b8959a2e05d2923ea6e4e
|
|
| BLAKE2b-256 |
f68cfe8992dcc020040db197356f5f4029f03d7d7fc0168d6b6bb9c4a09dbbb5
|