mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-14 02:47:16 +00:00
10 lines
346 B
Python
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)
|