diff --git a/action/config_template.py b/action/config_template.py index 10f6ebb..3abfdc0 100644 --- a/action/config_template.py +++ b/action/config_template.py @@ -204,19 +204,15 @@ class ConfigTemplateParser(ConfigParser.RawConfigParser): use_defaults = False option = self.optionxform(option) - try: - index = sectdict.index('#%s' % option) - except (ValueError, IndexError): - sectdict[option] = value - else: - if use_defaults: - self._defaults = sectdict.insert(index, option, value) + if use_defaults: + try: + index = sectdict.index('#%s' % option) + except (ValueError, IndexError): + sectdict[option] = value else: - self._sections[section] = sectdict.insert( - index, - option, - value - ) + self._defaults = sectdict.insert(index, option, value) + else: + sectdict[option] = value def _write(self, fp, section, key, item, entry): if section: diff --git a/tests/files/test_comment_configs.ini.expected b/tests/files/test_comment_configs.ini.expected index 652b879..1de6856 100644 --- a/tests/files/test_comment_configs.ini.expected +++ b/tests/files/test_comment_configs.ini.expected @@ -33,6 +33,7 @@ test = test1,test2 testopt1 = 9000 # This is another test opt #testop2 = over 9000 +testop2 = below 9000 [TestSection] things = stuff diff --git a/tests/test.yml b/tests/test.yml index 2e01a85..d9bbccb 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -181,6 +181,8 @@ - test2 TestSection: things: stuff + SubSection: + testop2: below 9000 diff_ini: added: DEFAULT: