Repository: KyleJamesWalker/yamlsettings

Issue:
Replace all non-variable characters to underscore in update_from_env
For example:
```python3
import os
import yamlsettings
from yamlsettings.yamldict import YAMLDict

os.environ['FOO_BAR'] = 'barbaz'

settings = YAMLDict({'foo-bar': None})
yamlsettings.update_from_env(settings)

assert settings['foo-bar'] == 'barbaz'
```

Discussion:

Patch:
diff --git a/setup.py b/setup.py
index d5957bc..51cbf92 100644
--- a/setup.py
+++ b/setup.py
@@ -26,7 +26,7 @@ requirements.update(all=sorted(set().union(*requirements.values())))
 
 setup(
     name='yamlsettings',
-    version='2.0.3',
+    version='2.1.0',
     description='Yaml Settings Configuration Module',
     long_description=readme,
     author='Kyle James Walker',
diff --git a/yamlsettings/helpers.py b/yamlsettings/helpers.py
index 50193b2..151b843 100644
--- a/yamlsettings/helpers.py
+++ b/yamlsettings/helpers.py
@@ -49,7 +49,7 @@ def update_from_env(yaml_dict, prefix=None):
         env_path = "{0}{1}{2}".format(
             prefix.upper(),
             '_' if prefix else '',
-            '_'.join([str(key).upper() for key in path])
+            '_'.join([str(key).replace('-', '_').upper() for key in path])
         )
         env_val = os.environ.get(env_path, None)
         if env_val is not None:


Test patch:
diff --git a/tests/test_yamldict.py b/tests/test_yamldict.py
index 66b44c0..747dfb9 100644
--- a/tests/test_yamldict.py
+++ b/tests/test_yamldict.py
@@ -12,7 +12,7 @@ import unittest
 
 from mock import mock_open
 from yamlsettings import (load, load_all, save_all,
-                          update_from_env, update_from_file)
+                          update_from_env, update_from_file, yamldict)
 
 from . import builtin_module, path_override, open_override, isfile_override
 
@@ -228,6 +228,14 @@ class YamlDictTestCase(unittest.TestCase):
         test_defaults.update({'a': (4,)})
         self.assertEqual(test_defaults.a, (4,))
 
+    @mock.patch.dict('os.environ', {'FOO_BAR': 'new-baz'})
+    def test_dash_vars_with_env(self):
+        """Test items with dashes can be overritten with env"""
+        test_settings = yamldict.YAMLDict({'foo-bar': 'baz'})
+        assert test_settings['foo-bar'] == 'baz'
+        update_from_env(test_settings)
+        assert test_settings['foo-bar'] == 'new-baz'
+
 
 if __name__ == '__main__':
     unittest.main()