# Path: grace/error.py
# class WrongFormatError(Error):
#     pass
# 
# class MissingKeyError(Error):
#     pass
# 
# class FileNotFoundError(Error):
#     pass
# 
# class KeyNotAllowedError(Error):
#     pass
# 
# Path: grace/utils.py
# def update(d, u):
#     for k, v in u.items():
#         if isinstance(v, collections.Mapping):
#             r = update(d.get(k, {}), v)
#             d[k] = r
#         else:
#             d[k] = u[k]
#     return d
# 
# def load_json(string):
#     obj = {}
# 
#     try:
#         obj = json.loads(string)
#     except ValueError as e:
#         raise e
# 
#     if sys.version_info.major < 3:
#         return _json_decode(obj)
# 
#     # if sys.version_info.major < 3:
#     #     d = _json_decode(obj)
#     #     if 'dizmo_settings' in d:
#     #         print(isinstance(d['dizmo_settings']['display_name'], str))
#     #         print(isinstance(d['dizmo_settings']['display_name'], unicode))
#     #         print(type(d['dizmo_settings']['display_name']))
#     #     return d
# 
#     return obj
# 
# def isstring(string):
#     if isinstance(string, str):
#         return True
# 
#     if sys.version_info.major < 3:
#         if isinstance(string, newstr):
#             return True
#         if isinstance(string, basestring):
#             return True
# 
#     return False


from builtins import object
from .error import WrongFormatError, MissingKeyError, FileNotFoundError, KeyNotAllowedError
from .utils import update, load_json, isstring
import os
import re
        except:
            raise

        try:
            config_file = open(os.path.join(cwd, 'project.cfg'))
        except:
            raise FileNotFoundError('Could not find a config file in this directory.')

        try:
            local_config = self._parse_config_file(config_file)
        except:
            raise

        return self._preparse_config(update(global_config, local_config))

    def _preparse_config(self, config):
        return config

    def _check_update_keys(self, updates):
        if 'name' in updates:
            raise KeyNotAllowedError('Can not overwrite the name configuration option.')
        if 'version' in updates:
            raise KeyNotAllowedError('Can not overwrite the version configuration option.')

    def _update_config(self, config, updates):
        try:
            self._check_update_keys(updates)
        except:
            raise


# Path: grace/error.py
# class WrongFormatError(Error):
#     pass
# 
# class MissingKeyError(Error):
#     pass
# 
# class FileNotFoundError(Error):
#     pass
# 
# class KeyNotAllowedError(Error):
#     pass
# 
# Path: grace/utils.py
# def update(d, u):
#     for k, v in u.items():
#         if isinstance(v, collections.Mapping):
#             r = update(d.get(k, {}), v)
#             d[k] = r
#         else:
#             d[k] = u[k]
#     return d
# 
# def load_json(string):
#     obj = {}
# 
#     try:
#         obj = json.loads(string)
#     except ValueError as e:
#         raise e
# 
#     if sys.version_info.major < 3:
#         return _json_decode(obj)
# 
#     # if sys.version_info.major < 3:
#     #     d = _json_decode(obj)
#     #     if 'dizmo_settings' in d:
#     #         print(isinstance(d['dizmo_settings']['display_name'], str))
#     #         print(isinstance(d['dizmo_settings']['display_name'], unicode))
#     #         print(type(d['dizmo_settings']['display_name']))
#     #     return d
# 
#     return obj
# 
# def isstring(string):
#     if isinstance(string, str):
#         return True
# 
#     if sys.version_info.major < 3:
#         if isinstance(string, newstr):
#             return True
#         if isinstance(string, basestring):
#             return True
# 
#     return False


# Path: grace/config.py
from builtins import object
from .error import WrongFormatError, MissingKeyError, FileNotFoundError, KeyNotAllowedError
from .utils import update, load_json, isstring
import os
import re

        except:
            raise

        try:
            config_file = open(os.path.join(cwd, 'project.cfg'))
        except:
            raise FileNotFoundError('Could not find a config file in this directory.')

        try:
            local_config = self._parse_config_file(config_file)
        except:
            raise

        return self._preparse_config(update(global_config, local_config))

    def _preparse_config(self, config):
        return config

    def _check_update_keys(self, updates):
        if 'name' in updates:
            raise KeyNotAllowedError('Can not overwrite the name configuration option.')
        if 'version' in updates:
            raise KeyNotAllowedError('Can not overwrite the version configuration option.')

    def _update_config(self, config, updates):
        try:
            self._check_update_keys(updates)
        except:
            raise


        return update(config, updates)