Пример #1
0
    def read(self, filenames):
        # read the ini file the standard way
        BaseConfigParser.read(self, filenames)

        # convert _defaults to SortedDict int _mydefaults
        self._mydefaults = SortedDict(self._defaults)

        # set it empty to avoid interference with other sections
        self._defaults = SortedDict()

        # convert as well all sections to SortedDict
        for section in self._sections:
            self._sections[section] = SortedDict(self._sections[section])

        # and finally, convert the section list itself to SortedDict
        self._sections = SortedDict(self._sections)
Пример #2
0
 def write(self, fp):
     # put _defaults back in place before writing
     self._mydefaults.update(self._defaults)
     self._defaults = self._mydefaults
     # write in alpha-sorted order
     BaseConfigParser.write(self, fp)
     # and set it back to an empty dict
     self._defaults = SortedDict()
Пример #3
0
 def add_section(self, section):
     # add a section the standard way
     BaseConfigParser.add_section(self, section)
     # and convert it to a SortedDict
     self._sections[section] = SortedDict()