# Path: vimswitch/DiskIo.py
# def getDiskIo(app):
#     return app.get('diskIo', createDiskIo(app))
# 
# Path: vimswitch/FileDownloader.py
# def getFileDownloader(app):
#     return app.get('fileDownloader', createFileDownloader(app))
# 
# Path: vimswitch/GithubZipballExtractor.py
# def getGithubZipballExtractor(app):
#     return app.get('githubZipballExtractor', createGithubZipballExtractor(app))
# 
# Path: vimswitch/ProfileCache.py
# def getProfileCache(app):
#     return app.get('profileCache', createProfileCache(app))
# 
# Path: vimswitch/ProfileUrlResolver.py
# def getProfileUrl(profile):
#     prefix = 'https://github.com/'
#     suffix = '/archive/master.zip'
#     url = prefix + profile.getName() + suffix
#     return url
# 
# Path: vimswitch/Settings.py
# def getSettings(app):
#     return app.get('settings', createSettings(app))


from .DiskIo import getDiskIo
from .FileDownloader import getFileDownloader
from .GithubZipballExtractor import getGithubZipballExtractor
from .ProfileCache import getProfileCache
from .ProfileUrlResolver import getProfileUrl
from .Settings import getSettings
import os
        self.diskIo = diskIo
        self.githubZipballExtractor = githubZipballExtractor

    def retrieve(self, profile):
        """
        Downloads a profile into the cache. If the profile already exists, then
        it is overwritten.
        """
        url = getProfileUrl(profile)
        print('Downloading profile from %s' % url)
        downloadsPath = self.settings.downloadsPath
        downloadedFilePath = self.fileDownloader.download(url, downloadsPath)
        extractionDir = os.path.splitext(downloadedFilePath)[0]
        self.githubZipballExtractor.extractZipball(downloadedFilePath, extractionDir)

        if self.profileCache.contains(profile):
            self.profileCache.delete(profile)

        profileDir = self.profileCache.getProfileLocation(profile)
        self.diskIo.move(extractionDir, profileDir)


def getProfileRetriever(app):
    return app.get('profileRetriever', createProfileRetriever(app))


def createProfileRetriever(app):
    settings = getSettings(app)
    fileDownloader = getFileDownloader(app)
    profileCache = getProfileCache(app)

# Path: vimswitch/DiskIo.py
# def getDiskIo(app):
#     return app.get('diskIo', createDiskIo(app))
# 
# Path: vimswitch/FileDownloader.py
# def getFileDownloader(app):
#     return app.get('fileDownloader', createFileDownloader(app))
# 
# Path: vimswitch/GithubZipballExtractor.py
# def getGithubZipballExtractor(app):
#     return app.get('githubZipballExtractor', createGithubZipballExtractor(app))
# 
# Path: vimswitch/ProfileCache.py
# def getProfileCache(app):
#     return app.get('profileCache', createProfileCache(app))
# 
# Path: vimswitch/ProfileUrlResolver.py
# def getProfileUrl(profile):
#     prefix = 'https://github.com/'
#     suffix = '/archive/master.zip'
#     url = prefix + profile.getName() + suffix
#     return url
# 
# Path: vimswitch/Settings.py
# def getSettings(app):
#     return app.get('settings', createSettings(app))


# Path: vimswitch/ProfileRetriever.py
from .DiskIo import getDiskIo
from .FileDownloader import getFileDownloader
from .GithubZipballExtractor import getGithubZipballExtractor
from .ProfileCache import getProfileCache
from .ProfileUrlResolver import getProfileUrl
from .Settings import getSettings
import os

        self.diskIo = diskIo
        self.githubZipballExtractor = githubZipballExtractor

    def retrieve(self, profile):
        """
        Downloads a profile into the cache. If the profile already exists, then
        it is overwritten.
        """
        url = getProfileUrl(profile)
        print('Downloading profile from %s' % url)
        downloadsPath = self.settings.downloadsPath
        downloadedFilePath = self.fileDownloader.download(url, downloadsPath)
        extractionDir = os.path.splitext(downloadedFilePath)[0]
        self.githubZipballExtractor.extractZipball(downloadedFilePath, extractionDir)

        if self.profileCache.contains(profile):
            self.profileCache.delete(profile)

        profileDir = self.profileCache.getProfileLocation(profile)
        self.diskIo.move(extractionDir, profileDir)


def getProfileRetriever(app):
    return app.get('profileRetriever', createProfileRetriever(app))


def createProfileRetriever(app):
    settings = getSettings(app)
    fileDownloader = getFileDownloader(app)
    profileCache = getProfileCache(app)

    diskIo = getDiskIo(app)