# Path: sshproxy/util.py
# class SortedDict(odict):
#     """
#     This class implements a dict with sorted keys.
#     This is less efficient than dict, but much nicer
#     to read for a human creature.
#     """
#     def values(self):
#         items = odict.items(self)
#         items.sort()
#         return [ odict.__getitem__(self, item) for item in items ]
# 
#     def items(self):
#         items = odict.items(self)
#         items.sort()
#         return items
# 
#     def keys(self):
#         keys = odict.keys(self)
#         keys.sort()
#         return keys
# 
#     def __iter__(self):
#         for key in self.keys():
#             yield key


from ConfigParser import NoSectionError, SafeConfigParser as BaseConfigParser
from sshproxy.util import SortedDict
    import ConfigParser as CP
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA




class FileConfigParser(BaseConfigParser):
    """
    This class is a wrapper to python's ConfigParser to avoid the
    automatic merge between a section and the DEFAULT section.
    It also forces ConfigParser to use SortedDict instead of builtin
    dict.
    """
    CP.__builtins__['dict'] = SortedDict

    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

# Path: sshproxy/util.py
# class SortedDict(odict):
#     """
#     This class implements a dict with sorted keys.
#     This is less efficient than dict, but much nicer
#     to read for a human creature.
#     """
#     def values(self):
#         items = odict.items(self)
#         items.sort()
#         return [ odict.__getitem__(self, item) for item in items ]
# 
#     def items(self):
#         items = odict.items(self)
#         items.sort()
#         return items
# 
#     def keys(self):
#         keys = odict.keys(self)
#         keys.sort()
#         return keys
# 
#     def __iter__(self):
#         for key in self.keys():
#             yield key


# Path: lib/ini_db/file.py
from ConfigParser import NoSectionError, SafeConfigParser as BaseConfigParser
from sshproxy.util import SortedDict
    import ConfigParser as CP

# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA




class FileConfigParser(BaseConfigParser):
    """
    This class is a wrapper to python's ConfigParser to avoid the
    automatic merge between a section and the DEFAULT section.
    It also forces ConfigParser to use SortedDict instead of builtin
    dict.
    """
    CP.__builtins__['dict'] = SortedDict

    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)