cfitall.providers.environment.EnvironmentProvider

class EnvironmentProvider(prefix, cast_bool=True, level_separator='__', provider_name='environment', value_separator=',', value_split=True)

Bases: cfitall.providers.base.ConfigProviderBase

EnvironmentProvider attempts to read configuration values from environment variables.

Parameters
  • prefix (str) – namespace prefix for environment variables (e.g. “myapp”)

  • cast_bool (bool) – attempt to cast “true” and “false” strings as booleans (True)

  • level_separator (str) – hierarchical separator in env variable name (“__”)

  • provider_name (str) – friendly name for the provider (“environment”)

  • value_separator (str) – string or regex to split lists on (“,”)

  • value_split (bool) – whether to split values enclosed in square brackets (True)

Methods

update

This is a no-op for the EnvironmentProvider, which always reads environment variables in realtime as doing so is a non-blocking call.

Attributes

dict

Returns the provider's configuration data from environment variables.

provider_name

each provider must provide a unique provider_name

cast_bool

whether to cast "true" and "false" strings to boolean values

level_separator

string used to separate dictionary keys in variable names

prefix

namespace for parsing variable names

value_separator

character used to separate delimited values

value_split

whether to split values on value_separator

cast_bool: bool

whether to cast “true” and “false” strings to boolean values

property dict: dict

Returns the provider’s configuration data from environment variables.

Return type

dict

level_separator: str

string used to separate dictionary keys in variable names

prefix: str

namespace for parsing variable names

update()

This is a no-op for the EnvironmentProvider, which always reads environment variables in realtime as doing so is a non-blocking call.

Return type

bool

value_separator: str

character used to separate delimited values

value_split: bool

whether to split values on value_separator