baseimage-tutorial-framework/lib/envvars.py
2018-02-09 17:37:56 +01:00

10 lines
346 B
Python

from collections import namedtuple
from os import environ
def generate_namedtuple_from_prefixed_envvars(prefix: str, tuple_name: str):
envvars = {envvar.replace(prefix, '', 1): environ.get(envvar)
for envvar in environ.keys()
if envvar.startswith(prefix)}
return namedtuple(tuple_name, envvars)(**envvars)