Skip to main content
zonar_ds_env_arg_parser
======

Overview
------
This is a simple helper that is meant to enforce and validate that environment variables are set correctly

Usage
------
```python3
from zonar_ds_env_arg_parser.env_arg_parser import env_arg_parser as parser

parser.add_argument(env_var="SOME_EVN_VAR",
required=True,
type=int,
help="Message to display about the variable")

parser.add_argument(env_var="SOMETHING_ELSE",
required=False,
default="TEST",
validation=lambda x: x.lower() == "test" or
x.lower() == "something" or
x.lower() == "something_else",
help="Some message about this variable")

parser.add_argument(env_var="TRUE",
required=False,
default="True",
type=bool, # Will convert ("yes", "true", "t", "1", "y", "yeah") to True
help="Another description about converting to True")

parser.initialize()
options = parser.get_options()

# This var doesn't have a default so 'SOME_EVN_VAR' needs to be set or it'll throw an exception
print("This is the type of SOME_EVN_VAR " + type(options.SOME_EVN_VAR)) # Should be int becasue we specified type
print("This is the value of SOMETHING_ELSE " + options.ENVIRONMENT) # Should be 'TEST' since that's the default
print("This is the value of TRUE " + options.TRUE) # Should be 'TEST' since that's the default
```

Arguments
------
Parameters that can be passed into env_arg_parser.add_argument are as follows:

| param | required | Description |
|-------|----------|-------------|
| env_var | Yes | The environment variable to look for. This will also be the name of the attribute when retrieving it. |
| required | Yes | Can be True or False, if required=False a default must be provided. |
| help | Yes | This message is displayed if an argument doesnt exist or fails validation. It should explain to the user what the argument is for to assist them in defining it. |
| default | Conditional | The default value. Must be set if required=False, cannot be set if required=True. |
| validation | No | A function should be provided that takes a single value and should return True, False or raise an Exception. False or an exception will prevent the program from launching. |
| type | No | If the value needs to be something other than a string, specify what it should be converted to.


Release files for zonar-ds-env-arg-parser 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zonar-ds-env-arg-parser 1.0.1
File Size Uploaded
zonar_ds_env_arg_parser-1.0.1.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zonar-ds-env-arg-parser 1.0.1
File Interpreter ABI Platform
zonar_ds_env_arg_parser-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / zonar_ds_env_arg_parser-1.0.1.tar.gz

Download URL zonar_ds_env_arg_parser-1.0.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a2e9c1b56a181739d30d7672aed38b400005ca19370152ac183efa3041024cd6
BLAKE2b-256 checksum
How to use checksums
26881f2f8a5c94cf5be0b11b550f22697a94551fe59297b58c2fc305032cd4ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Release files / zonar_ds_env_arg_parser-1.0.1-py3-none-any.whl

Download URL zonar_ds_env_arg_parser-1.0.1-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0f9fff3c69fcb1d911e62408be1b84487a0ec7628db419128c8360882ce2d2a
BLAKE2b-256 checksum
How to use checksums
8a7d12adc0b479322444621d8890a409d51e06d09d37c10fd5f017a37b0caac5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page