# Path: grace/error.py
# class FileNotWritableError(Error):
#     pass
# 
# class FolderAlreadyExistsError(Error):
#     pass
# 
# class FolderNotFoundError(Error):
#     pass
# 
# class CreateFolderError(Error):
#     pass
# 
# class FileNotFoundError(Error):
#     pass
# 
# class GeneralError(Error):
#     pass
# 
# Path: grace/utils.py
# def get_path():
#     encoding = sys.getfilesystemencoding()
#     if we_are_frozen():
#         return os.path.dirname(sys.executable)
#     return os.path.dirname(__file__)


from builtins import object
from .error import FileNotWritableError, FolderAlreadyExistsError, FolderNotFoundError, CreateFolderError, FileNotFoundError, GeneralError
from shutil import copytree, copy, rmtree
from pkg_resources import resource_filename
from .utils import get_path
import os
import sys
import re
import requests
import tempfile
import zipfile
import hashlib


class Assets(object):
    def __init__(self, projectName):
        self._projectName = projectName
        self._root = get_path()
        self._cwd = os.getcwd()

        try:
            self._assetPath = os.path.join(resource_filename(__name__, os.path.join('assets', 'manage.py')))
        except NotImplementedError:
            self._assetPath = os.path.join(sys.prefix, 'assets', 'manage.py')

        self._projectPath = os.path.join(self._cwd, self._projectName)

        self._copy_assets()

    def _copy_assets(self):
        if not os.path.exists(self._assetPath):
            raise FileNotFoundError('Could not find the manage.py asset.')

        try:
            copy(self._assetPath, os.path.join(self._cwd, self._projectName))
        except:
            raise FileNotWritableError('Could not create the manage.py file.')


class New(object):
    def __init__(self, projectName, skeleton):
        self._projectName = projectName

# Path: grace/error.py
# class FileNotWritableError(Error):
#     pass
# 
# class FolderAlreadyExistsError(Error):
#     pass
# 
# class FolderNotFoundError(Error):
#     pass
# 
# class CreateFolderError(Error):
#     pass
# 
# class FileNotFoundError(Error):
#     pass
# 
# class GeneralError(Error):
#     pass
# 
# Path: grace/utils.py
# def get_path():
#     encoding = sys.getfilesystemencoding()
#     if we_are_frozen():
#         return os.path.dirname(sys.executable)
#     return os.path.dirname(__file__)


# Path: grace/create.py
from builtins import object
from .error import FileNotWritableError, FolderAlreadyExistsError, FolderNotFoundError, CreateFolderError, FileNotFoundError, GeneralError
from shutil import copytree, copy, rmtree
from pkg_resources import resource_filename
from .utils import get_path
import os
import sys
import re
import requests
import tempfile
import zipfile
import hashlib



class Assets(object):
    def __init__(self, projectName):
        self._projectName = projectName
        self._root = get_path()
        self._cwd = os.getcwd()

        try:
            self._assetPath = os.path.join(resource_filename(__name__, os.path.join('assets', 'manage.py')))
        except NotImplementedError:
            self._assetPath = os.path.join(sys.prefix, 'assets', 'manage.py')

        self._projectPath = os.path.join(self._cwd, self._projectName)

        self._copy_assets()

    def _copy_assets(self):
        if not os.path.exists(self._assetPath):
            raise FileNotFoundError('Could not find the manage.py asset.')

        try:
            copy(self._assetPath, os.path.join(self._cwd, self._projectName))
        except:
            raise FileNotWritableError('Could not create the manage.py file.')


class New(object):
    def __init__(self, projectName, skeleton):
        self._projectName = projectName

        self._root = get_path()