staffanm / layeredconfig

Manages configuration coming from config files, environment variables, command line arguments, code defaults or other sources
BSD 3-Clause "New" or "Revised" License
18 stars 8 forks source link

[Bug] unable to load multiple yaml files with dicts #2

Closed badkapitan closed 8 years ago

badkapitan commented 8 years ago

Test case:

1.yaml:

a:
  b: b

2.yaml

somevar: value 

layeredconfigbug.py:

from layeredconfig import LayeredConfig, YAMLFile
yamls = [YAMLFile('1.yaml'), YAMLFile('2.yaml')]
cfg = LayeredConfig(*yamls)

executing layeredconfigbug.py crashes on last line with:

Traceback (most recent call last):
  File "layeredconfigbug.py", line 7, in <module>
    cfg = LayeredConfig(*yamls)
  File "/usr/local/lib/python2.7/dist-packages/layeredconfig/layeredconfig.py", line 87, in __init__
    cascade=self._cascade))
  File "/usr/local/lib/python2.7/dist-packages/layeredconfig/yamlfile.py", line 29, in __init__
    with codecs.open(yamlfilename, encoding="utf-8") as fp:
  File "/usr/lib/python2.7/codecs.py", line 881, in open
    file = __builtin__.open(filename, mode, buffering)
TypeError: coercing to Unicode: need string or buffer, NoneType found

Tested with layeredconfig 0.2.1, 0.2.2.dev1

staffanm commented 8 years ago

Excellent bug report -- I can confirm that I see the same issue. Will try to fix it and release version 0.2.2 ASAP.

badkapitan commented 8 years ago

Great to hear that, can't wait for the fix ;)

staffanm commented 8 years ago

Fixed by the PR from @badkapitan

staffanm commented 8 years ago

Version 0.2.2 is now up on pypi. Again, thanks for the help!

badkapitan commented 8 years ago

Not a problem, glad I could help :) Good luck with the rest! :)