Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_generate_uppercase_key(key, ns, expected):
full_key = generate_uppercase_key(key, ns)
assert full_key == expected
def get(self, key, namespace=None):
"""Retrieve value for key."""
if not self.path:
return NO_VALUE
# NOTE(willkg): The "main" section is considered the root mainspace.
namespace = namespace or ["main"]
logger.debug("Searching %r for key: %s, namespace: %s", self, key, namespace)
full_key = generate_uppercase_key(key, namespace)
return get_key_from_envs(self.cfg, full_key)
def get(self, key, namespace=None):
"""Retrieve value for key."""
if not self.path:
return NO_VALUE
logger.debug("Searching %r for key: %s, namepsace: %s", self, key, namespace)
full_key = generate_uppercase_key(key, namespace)
return get_key_from_envs(self.cfg, full_key)
def get(self, key, namespace=None):
name = generate_uppercase_key(key, namespace).lower()
if name in self.cache:
return self.cache[name]
parser = argparse.ArgumentParser()
parser.add_argument(f'--{name}')
args = parser.parse_known_args([name])
res = getattr(args, name, NO_VALUE)
self.cache[name] = res
return res