Skip to main content

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 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 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


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-1.2.6.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

egos_helpers-1.2.6-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file egos_helpers-1.2.6.tar.gz.

File metadata

  • Download URL: egos_helpers-1.2.6.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for egos_helpers-1.2.6.tar.gz
Algorithm Hash digest
SHA256 80ab25b1153b36695e2e10e5b847b7ce88ed5d6a4d1c4b2a3b37bd09c228a827
MD5 cad156442926b78026629578f1b07900
BLAKE2b-256 0cfcc4bc23fcb06e4a8feb0c079ab99c42f75138590a8bb95ecd7ec6de2b6a7b

See more details on using hashes here.

File details

Details for the file egos_helpers-1.2.6-py3-none-any.whl.

File metadata

  • Download URL: egos_helpers-1.2.6-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for egos_helpers-1.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3f5de8154fce928b938c14735b9c9e9c5b6e2ed6f647fb3a56959498ff5cffbf
MD5 5f48cf8130ac5e8838f8afaf7f572731
BLAKE2b-256 057cba5614b3c236b9b87eb4e57691adf4f6ec0bf87085da468c3549c672fd2c

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