# Path: grace/error.py
# class FileNotWritableError(Error):
#     pass
# 
# class RemoveFileError(Error):
#     pass
# 
# class MissingKeyError(Error):
#     pass


from builtins import object
from .error import FileNotWritableError, RemoveFileError, MissingKeyError
import os
import zipfile
            if self._zip_path is not None:
                self._zip(name, source, os.path.join(self._zip_path, zip_name))
        except:
            raise

    def _zip(self, name, source, dest):
        try:
            self._cleanup(dest)
        except:
            raise

        try:
            z = zipfile.ZipFile(dest, 'a', zipfile.ZIP_DEFLATED)
        except RuntimeError as e:
            z = zipfile.ZipFile(dest, 'a')

        for root, dirs, files in os.walk(source):
            for f in files:
                tmpfilename = os.path.join(root, f).split(source)[1][1:]
                zipfilename = os.path.join(name, tmpfilename)
                try:
                    z.write(os.path.join(root, f), zipfilename)
                except:
                    raise FileNotWritableError('Could not write to the zip file.')

        z.close()

    def _cleanup(self, path):

        if os.path.exists(path):

# Path: grace/error.py
# class FileNotWritableError(Error):
#     pass
# 
# class RemoveFileError(Error):
#     pass
# 
# class MissingKeyError(Error):
#     pass


# Path: grace/zipit.py
from builtins import object
from .error import FileNotWritableError, RemoveFileError, MissingKeyError
import os
import zipfile

            if self._zip_path is not None:
                self._zip(name, source, os.path.join(self._zip_path, zip_name))
        except:
            raise

    def _zip(self, name, source, dest):
        try:
            self._cleanup(dest)
        except:
            raise

        try:
            z = zipfile.ZipFile(dest, 'a', zipfile.ZIP_DEFLATED)
        except RuntimeError as e:
            z = zipfile.ZipFile(dest, 'a')

        for root, dirs, files in os.walk(source):
            for f in files:
                tmpfilename = os.path.join(root, f).split(source)[1][1:]
                zipfilename = os.path.join(name, tmpfilename)
                try:
                    z.write(os.path.join(root, f), zipfilename)
                except:
                    raise FileNotWritableError('Could not write to the zip file.')

        z.close()

    def _cleanup(self, path):

        if os.path.exists(path):

            try: