Metadata-Version: 2.3
Name: egos-helpers
Version: 1.2.0
Summary: A python library for helper functions
License: MIT License
         
         Copyright (c) 2025 egos.tech
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
Author: Alex Thomae
Author-email: egos-helpers@egos.tech
Requires-Python: >=3.12
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: pygelf (==0.4.3)
Project-URL: Homepage, https://gitlab.com/egos-tech/egos-helpers
Project-URL: Source, https://gitlab.com/egos-tech/egos-helpers
Description-Content-Type: text/markdown

# egos-helpers

A python library for helper functions. Used in the [egos-tech](https://gitlab.com/egos-tech) projects.

## Functions

* `gather_environ`: Return a dict of environment variables correlating to the keys dict.
* `short_msg`: Truncates the message to `chars` characters and adds two dots at the end.
* `strtobool`: Converts a string to a boolean
* `redact`: Replaces in `message` the `param` string with `replace_value`

See [egos_helpers/core.py](https://gitlab.com/egos-tech/egos-helpers/-/blob/main/egos_helpers/core.py) for the full description of each function.

## Usage example

Install `egos-helpers`:

```sh
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:

```py
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)
```

