# Path: vimswitch/DiskIo.py
# def getDiskIo(app):
#     return app.get('diskIo', createDiskIo(app))
# 
# Path: vimswitch/Profile.py
# class Profile:
#     def __init__(self, name):
#         self.name = name
# 
#     def getName(self):
#         return self.name
# 
#     def getDirName(self):
#         return self.name.replace('/', '.')
# 
#     def __eq__(self, other):
#         return isinstance(other, Profile) and self.name == other.name
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def __repr__(self):
#         return "Profile('%s')" % self.name


from .DiskIo import getDiskIo
from .Profile import Profile
from .six import StringIO
from .six.moves.configparser import SafeConfigParser


class ConfigFile:
    def __init__(self, diskIo):
        self.diskIo = diskIo

    def loadSettings(self, settings, path):
        """
        Reads the config file at path and applies the values to settings. If
        path does not exist, then settings will be left unchanged.
        """
        if self.diskIo.fileExists(path):
            settingsIo = StringIO(self.diskIo.getFileContents(path))
            config = self._getConfigParser()
            config.readfp(settingsIo)

            currentProfileName = config.get('settings', 'currentProfile')
            if currentProfileName is None:
                settings.currentProfile = None
            else:

# Path: vimswitch/DiskIo.py
# def getDiskIo(app):
#     return app.get('diskIo', createDiskIo(app))
# 
# Path: vimswitch/Profile.py
# class Profile:
#     def __init__(self, name):
#         self.name = name
# 
#     def getName(self):
#         return self.name
# 
#     def getDirName(self):
#         return self.name.replace('/', '.')
# 
#     def __eq__(self, other):
#         return isinstance(other, Profile) and self.name == other.name
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def __repr__(self):
#         return "Profile('%s')" % self.name


# Path: vimswitch/ConfigFile.py
from .DiskIo import getDiskIo
from .Profile import Profile
from .six import StringIO
from .six.moves.configparser import SafeConfigParser



class ConfigFile:
    def __init__(self, diskIo):
        self.diskIo = diskIo

    def loadSettings(self, settings, path):
        """
        Reads the config file at path and applies the values to settings. If
        path does not exist, then settings will be left unchanged.
        """
        if self.diskIo.fileExists(path):
            settingsIo = StringIO(self.diskIo.getFileContents(path))
            config = self._getConfigParser()
            config.readfp(settingsIo)

            currentProfileName = config.get('settings', 'currentProfile')
            if currentProfileName is None:
                settings.currentProfile = None
            else:

                settings.currentProfile = Profile(currentProfileName)