# 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
                file_list.append({
                    'file': f,
                    'path': path
                })

        for entry in file_list:
            if re.search('_X.', entry['file']):
                try:
                    self._replace(entry)
                except:
                    raise

    def _replace(self, fileObject):
        f = fileObject['file']
        p = fileObject['path']

        outfilename = f.replace('_X', '')
        with open(os.path.join(p, outfilename), 'w+') as out:
            infile = open(os.path.join(p, f))
            for line in infile:
                newline = line.replace('##PROJECTNAME##', self._projectName)
                newline = newline.replace('##PROJECTNAME_TOLOWER##', self._projectName.lower())

                out.write(newline)

            infile.close()

        try:
            os.remove(os.path.join(p, f))
        except:

# 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

                file_list.append({
                    'file': f,
                    'path': path
                })

        for entry in file_list:
            if re.search('_X.', entry['file']):
                try:
                    self._replace(entry)
                except:
                    raise

    def _replace(self, fileObject):
        f = fileObject['file']
        p = fileObject['path']

        outfilename = f.replace('_X', '')
        with open(os.path.join(p, outfilename), 'w+') as out:
            infile = open(os.path.join(p, f))
            for line in infile:
                newline = line.replace('##PROJECTNAME##', self._projectName)
                newline = newline.replace('##PROJECTNAME_TOLOWER##', self._projectName.lower())

                out.write(newline)

            infile.close()

        try:
            os.remove(os.path.join(p, f))
        except:

            raise FileNotWritableError('Could not delete the initial replace file.')