baseimage-tutorial-framework/lib/envvars/__init__.py
2018-05-10 16:20:58 +02:00

13 lines
446 B
Python

# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
# All Rights Reserved. See LICENSE file for details.
from collections import namedtuple
from os import environ
def prefixed_envvars_to_namedtuple(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)