A python library for helper functions
Project description
egos-helpers
A python library for helper functions. Used in the egos-tech projects.
Functions
gather_environ: Return a dict of environment variables correlating to the keys dict.short_msg: Truncates the message tocharscharacters and adds two dots at the end.strtobool: Converts a string to a booleanredact: Replaces inmessagetheparamstring withreplace_value
See egos_helpers/core.py for the full description of each function.
Usage example
Install egos-helpers:
python3 -m venv .venv
source .venv/bin/activate
# if you don't have a requirements.txt file
pip install -U egos-helpers
# if you do have a requirements.txt file
pip install -U -r requirements.txt
In your python project:
from egos_helpers import gather_environ
class MyClass:
keys = {
'key_one': {
'default': ['one', 2],
'type': "list",
},
'key_two':{
'hidden': True,
'default': False,
'type': "boolean",
},
'key_three': {
'default': [],
'type': "filter",
},
'key_four': {
'default': None,
'redact': True,
'type': 'string',
},
'key_five': {
'default': 12,
'type': 'int',
},
'key_six': {
'default': 'INFO',
'type': 'enum',
'values': [
'DEBUG',
'INFO',
'WARNING',
'ERROR'
],
},
'key_seven': {
'default': '12',
'deprecated': True,
'replaced_by': 'key_five',
'type': 'int',
}
}
def __init__(self):
envkeys = gather_environ(keys=MyClass.keys)
print(envkeys)
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
egos_helpers-0.5.3.tar.gz
(7.9 kB
view details)
File details
Details for the file egos_helpers-0.5.3.tar.gz.
File metadata
- Download URL: egos_helpers-0.5.3.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d815166ed016b0e7850152e2bbd8bdc03d0dc0a0dba058cf4716075b111cc5ab
|
|
| MD5 |
bf8f114d8bf21cfd6cc7143d9098b1df
|
|
| BLAKE2b-256 |
754aa13277a0f2bd35df36845be417fad4ce58c90fdda67aaf9170bd7ee13dac
|