diff options
Diffstat (limited to 'reconfigure/parsers/ini.py')
-rw-r--r-- | reconfigure/parsers/ini.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/reconfigure/parsers/ini.py b/reconfigure/parsers/ini.py index 2f95d33..851bfb8 100644 --- a/reconfigure/parsers/ini.py +++ b/reconfigure/parsers/ini.py @@ -1,4 +1,4 @@ -import six +import sys from reconfigure.nodes import * from reconfigure.parsers import BaseParser @@ -44,6 +44,7 @@ class IniFileParser (BaseParser): name = None section_node = Node(name) section_node.comment = self._get_comment(cp[section]._lines[0]) + section_node._extra_content = {} for option in cp[section]: if option in cp[section]._options: node = PropertyNode(option, cp[section][option]) @@ -66,10 +67,15 @@ class IniFileParser (BaseParser): cp[sectionname][option.name] = option.value if option.comment: self._set_comment(cp[sectionname]._options[option.name], option.comment) + + if section._extra_content: + for k, v in section._extra_content.items(): + cp[sectionname][k] = v + if hasattr(cp[sectionname], '_lines'): self._set_comment(cp[sectionname]._lines[0], section.comment) - data = (str if six.PY3 else unicode)(cp) + u'\n' + data = (str if sys.version_info[0] >= 3 else unicode)(cp) + u'\n' if self.sectionless: data = data.replace('[' + self.nullsection + ']\n', '') return data |