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

Nested sections in YAML and Commandline() causes exception #8

Closed AnsonT closed 8 years ago

AnsonT commented 8 years ago

YAML file

Section:
   Subsection:
      Key: value
config_file = YAMLFile("config.yml")
command_line = Commandline()
LayeredConfig(config_file, command_line)

Causes the following exception

  File ".../config.py", line 34, in loadConfig
    config = LayeredConfig(config_file, command_line)
  File ".../layeredconfig/layeredconfig.py", line 92, in __init__
    writable=self._writable)
  File ".../layeredconfig/layeredconfig.py", line 76, in __init__
    if k in list(src.subsections()):
  File ".../layeredconfig/commandline.py", line 184, in subsections
    for args in dict(self.source._get_kwargs()).keys():
AttributeError: 'NoneType' object has no attribute '_get_kwargs'
staffanm commented 8 years ago

Thanks for the report! I've verified it and made a testcase + fix, to be committed right away. Hopefully a 0.3.1 version will be released before the end of the week.