예제 #1
0
    def load(self, formatter=None):
        env_keys = self.keys + list(self.mapping.keys())

        for key in [format_key(k) for k in env_keys]:
            env_value = os.environ.get(format_key(key))

            if env_value is not None:
                if key in self.mapping:
                    self[self.format(self.mapping[key], self.formatter)] = env_value
                else:
                    self[self.format(key, self.formatter)] = env_value
예제 #2
0
 def __init__(self, *keys, **mapping):
     super(Env, self).__init__()
     self.keys = [format_key(k) for k in keys]
     self.mapping = dict(
         (format_key(k), format_key(v)) for k, v in mapping.items())
예제 #3
0
def test_format_env_key_with_mixed_case():
    assert format_key('abC 123') == 'ABC_123'
예제 #4
0
def test_format_env_key_with_trailing_spaces():
    assert format_key('   abc 123  ') == 'ABC_123'
예제 #5
0
def test_format_env_key_with_upper_case():
    assert format_key('ABC 123') == 'ABC_123'
예제 #6
0
def test_format_env_key_with_lower_case():
    assert format_key('abc 123') == 'ABC_123'
예제 #7
0
파일: env.py 프로젝트: ggreg/etcaetera
 def __init__(self, *keys, **mapping):
     super(Env, self).__init__()
     self.keys = [format_key(k) for k in keys]
     self.mapping = {format_key(k): format_key(v) for k, v in mapping.items()}
예제 #8
0
def test_format_env_key_with_mixed_case():
    assert format_key('abC 123') == 'ABC_123'
예제 #9
0
def test_format_env_key_with_trailing_spaces():
    assert format_key('   abc 123  ') == 'ABC_123'
예제 #10
0
def test_format_env_key_with_upper_case():
    assert format_key('ABC 123') == 'ABC_123'
예제 #11
0
def test_format_env_key_with_lower_case():
    assert format_key('abc 123') == 'ABC_123'