baseimage-tutorial-framework/lib/envvars.py

10 lines
346 B
Python
Raw Normal View History

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)