env_csv

privex.helpers.common.env_csv(env_key: str, env_default=None, csvsplit=',') → List[str][source]

Quick n’ dirty parsing of simple CSV formatted environment variables, with fallback to user specified env_default (defaults to None)

Example:

>>> import os
>>> os.environ['EXAMPLE'] = '  hello ,  world, test')
>>> env_csv('EXAMPLE', [])
['hello', 'world', 'test']
>>> env_csv('NONEXISTANT', [])
[]
Parameters
  • env_key (str) – Environment var to attempt to load

  • env_default (any) – Fallback value if the env var is empty / not set (Default: None)

  • csvsplit (str) – A character (or several) used to terminate each value in the list. Default: comma ,

Return List[str] parsed_data

A list of str values parsed from the env var