Package: rhea
rheaEfficient environment variables management and typing for python.Installationpip install -U rheaFeaturesTyped retrieval of environment variables.Handling of optional, secret, and local variables.Reading from different sources: os, json files, yaml files.Collection of parsed parameters.UsageReading typed values from a paramsfromrheaimportRhearhea_config=Rhea(bool_value1='1',bool_value2='false',bool_value3=True)rhea_config.get_boolean('bool_value1')# Truerhea_config.get_boolean('bool_value2')# Falserhea_config.get_boolean('bool_value3')# TrueReading typed values from a env varsimportosfromrheaimportRhearhea_config=Rhea.read_configs(os.environ)Reading typed values from different sourcesimportosfromrheaimportRhearhea_config=Rhea.read_configs([os.environ,'json_file.json','yaml_file.yaml','another_file_override.json',{'foo':'bar'}])Base typesexamples:BOOL_ENV_VALUE1: 1
BOOL_ENV_VALUE2: true
BOOL_ENV_VALUE3: f
BOOL_ENV_VALUE4: on

INT_ENV_VALUE1: '1' 
INT_ENV_VALUE2: -100

STRING_ENV_VALUE: 'some string'

FLOAT_ENV_VALUE1: '1.1'
FLOAT_ENV_VALUE2: -1.3
FLOAT_ENV_VALUE3: 1111.1
FLOAT_ENV_VALUE4: -33

DICT_ENV_VALUE: {"foo": "bar", "1": "2"}

LIST_ENV_VALUE: 'foo, bar, boo'

URI_ENV_VALUE1: user:pass@host.com
URI_ENV_VALUE2: user:pass@host:4000

AUTH_ENV_VALUE: user:passReading:fromrheaimportRhearhea_config=Rhea.read_configs([...])rhea_config.get_boolean('BOOL_ENV_VALUE1')# Truerhea_config.get_boolean('BOOL_ENV_VALUE2')# Truerhea_config.get_boolean('BOOL_ENV_VALUE3')# Falserhea_config.get_boolean('BOOL_ENV_VALUE4')# Truerhea_config.get_int('INT_ENV_VALUE1')# 1rhea_config.get_int('INT_ENV_VALUE2')# -100rhea_config.get_string('STRING_ENV_VALUE')# some stringrhea_config.get_float('FLOAT_ENV_VALUE1')# 1.1rhea_config.get_float('FLOAT_ENV_VALUE1')# -1.3rhea_config.get_float('FLOAT_ENV_VALUE1')# 1111.1rhea_config.get_float('FLOAT_ENV_VALUE1')# -33.0rhea_config.get_dict('DICT_ENV_VALUE')# {'foo': 'bar', '1': '2'}rhea_config.get_list('LIST_ENV_VALUE')# ['foo', 'bar', 'boo']rhea_config.get_uri('URI_ENV_VALUE1')# UriSpec('user', 'pass', 'host')rhea_config.get_uri('URI_ENV_VALUE2')# UriSpec('user', 'pass', 'host:4000')rhea_config.get_uri('AUTH_ENV_VALUE')# AuthSpec('user', 'pass')List of base typesexamples:BOOLS_ENV_VALUE: '[1, 0, "true", "false", "t", "f", "on", "off"]'
INTS_ENV_VALUE: '[1, 0, -100]'
STRINGS_ENV_VALUE: '["some_string", "another_string"]'
FLOATS_ENV_VALUE: '[1.1, -1.3, 0.03, 1111.1, 1.]'
DICTS_ENV_VALUE: '[{"foo": "bar", "1": 2}, {"foo": "bar", "1": 2}]'
DICT_OF_DICTS_ENV_VALUE: '{"key1": {"foo": "bar", "1": 2}, "key2": {"foo": "bar", "1": 2}}'
URIS_ENV_VALUE: '["user:pass@host.com", "user:pass@host:4000"]'
AUTHS_ENV_VALUE: '["user1:pass1", "user2:pass2"]'Reading:fromrheaimportRhearhea_config=Rhea.read_configs([...])rhea_config.get_boolean('BOOLS_ENV_VALUE',is_list=True)#  [True, False, True, False, True, False, True, False]rhea_config.get_int('INTS_ENV_VALUE',is_list=True)# [1, 0, -100]rhea_config.get_string('STRINGS_ENV_VALUE',is_list=True)# ['some_string', 'another_string']rhea_config.get_float('FLOATS_ENV_VALUE',is_list=True)# [1.1, -1.3, 0.03, 1111.1, 1.0]rhea_config.get_dict('DICTS_ENV_VALUE',is_list=True)# [{'foo1': 'bar1', '1': 2}, {'foo2': 'bar2', '3': 4}]rhea_config.get_dict_of_dicts('DICT_OF_DICTS_ENV_VALUE')# {'key1': {'foo': 'bar', '1': 2}, 'key2': {'foo': 'bar', '1': 2}}rhea_config.get_uri('URIS_ENV_VALUE',is_list=True)# [UriSpec('user', 'pass', 'host'), UriSpec('user', 'pass', 'host:4000')]rhea_config.get_uri('AUTHS_ENV_VALUE',is_list=True)# [UriSpec('user1', 'pass1'), UriSpec('user2', 'pass2')]Optional values and default valuesfromrheaimportRhearhea_config=Rhea.read_configs([...])rhea_config.get_boolean('BOOL_ENV_VALUE',is_optional=True)# Nonerhea_config.get_boolean('BOOL_ENV_VALUE',is_optional=True,default=True)# Truerhea_config.get_int('INT_ENV_VALUE',is_optional=True)# Nonerhea_config.get_int('INT_ENV_VALUE',is_optional=True,default=101)# 101rhea_config.get_float('FLOAT_ENV_VALUE',is_optional=True)# Nonerhea_config.get_float('FLOAT_ENV_VALUE',is_optional=True,default=-3.3)# -3.3rhea_config.get_float('STRING_ENV_VALUE',is_optional=True)# Nonerhea_config.get_float('STRING_ENV_VALUE',is_optional=True,default='default')# defaultValue validationfromrheaimportRhearhea_config=Rhea.read_configs([...])# INT_ENV_VALUE = 11rhea_config.get_int('INT_ENV_VALUE',options=[1,2,3])# raise RheaErrorrhea_config.get_int('INT_ENV_VALUE',options=[1,2,3,11])# 11Parsed datafromrheaimportRhearhea_config=Rhea.read_configs([...])rhea_config.get_requested_data(include_locals=False,include_secrets=False)# {'key1': 'value1', ...}Example with DjangofromrheaimportRhearhea_config=Rhea.read_configs([...])DEBUG=rhea_config.get_boolean('DJANGO_DEBUG_MODE',is_optional=True,default=False)SECRET_KEY=rhea_config.get_string('POLYAXON_SECRET_KEY',is_secret=True)Running testspytestLicense