# Path: grace/error.py
# class MissingKeyError(Error):
#     pass
# 
# class RemoveFolderError(Error):
#     pass
# 
# class FolderNotWritableError(Error):
#     pass


from builtins import object
from .error import MissingKeyError, RemoveFolderError, FolderNotWritableError
from shutil import rmtree, copytree
import os
from __future__ import print_function
from __future__ import absolute_import


class Deploy(object):
    def __init__(self, config):
        self._cwd = os.getcwd()
        self._config = config

        if 'deployment_path' not in self._config:
            raise MissingKeyError('Could not find deployment path in config file.')
        else:
            self._deployment_path = self._config['deployment_path']

    def run(self, testname):
        if self._config['test']:
            if testname is None:
                print('No tests to build.')
                return

            dest = os.path.join(self._deployment_path, self._config['name'] + '_' + testname)
            source = os.path.join(self._cwd, 'build', self._config['name'] + '_' + testname)
        elif self._config['build']:
            dest = os.path.join(self._deployment_path, self._config['name'])
            source = os.path.join(self._cwd, 'build', self._config['name'])
        else:

# Path: grace/error.py
# class MissingKeyError(Error):
#     pass
# 
# class RemoveFolderError(Error):
#     pass
# 
# class FolderNotWritableError(Error):
#     pass


# Path: grace/deploy.py
from builtins import object
from .error import MissingKeyError, RemoveFolderError, FolderNotWritableError
from shutil import rmtree, copytree
import os

from __future__ import print_function
from __future__ import absolute_import


class Deploy(object):
    def __init__(self, config):
        self._cwd = os.getcwd()
        self._config = config

        if 'deployment_path' not in self._config:
            raise MissingKeyError('Could not find deployment path in config file.')
        else:
            self._deployment_path = self._config['deployment_path']

    def run(self, testname):
        if self._config['test']:
            if testname is None:
                print('No tests to build.')
                return

            dest = os.path.join(self._deployment_path, self._config['name'] + '_' + testname)
            source = os.path.join(self._cwd, 'build', self._config['name'] + '_' + testname)
        elif self._config['build']:
            dest = os.path.join(self._deployment_path, self._config['name'])
            source = os.path.join(self._cwd, 'build', self._config['name'])
        else:

            raise MissingKeyError('It seems you are trying to deploy a project but neither build nor test were specified. I am sorry but I do not know what to do now.')