# 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

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

        return update(config, updates)

    def _parse_config_file(self, config_file):
        strings = []
        for line in config_file:
            if not re.search('^\s*//.*', line):
                strings.append(line.strip())

        try:
            return load_json(''.join(strings))
        except:
            raise WrongFormatError('The provided configuration file could not be parsed.')

    def _parse_config(self):
        cwd = os.getcwd()

        if 'name' not in self._config:
            raise MissingKeyError('Name of the project needs to be in the config file.')
        else:
            if not isstring(self._config['name']):
                raise WrongFormatError('The name key in your config file must be a string!')
            else:
                if len(self._config['name']) == 0:

# 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


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

        return update(config, updates)

    def _parse_config_file(self, config_file):
        strings = []
        for line in config_file:
            if not re.search('^\s*//.*', line):
                strings.append(line.strip())

        try:
            return load_json(''.join(strings))
        except:
            raise WrongFormatError('The provided configuration file could not be parsed.')

    def _parse_config(self):
        cwd = os.getcwd()

        if 'name' not in self._config:
            raise MissingKeyError('Name of the project needs to be in the config file.')
        else:
            if not isstring(self._config['name']):
                raise WrongFormatError('The name key in your config file must be a string!')
            else:
                if len(self._config['name']) == 0:

                    raise WrongFormatError('The name key in your config file must be at least one character long.')