# Path: g_sorcery/compatibility.py
# class TemporaryDirectory(object):
#     def __init__(self):
#     def __del__(self):
# 
# Path: g_sorcery/fileutils.py
# class FileJSON(FileJSONData):
#     """
#     Class for JSON files. Supports custom JSON serialization
#     provided by g_sorcery.serialization.
#     """
# 
#     def read_content(self):
#         """
#         Read JSON file.
#         """
#         content = {}
#         with open(self.path, 'r') as f:
#             content = json.load(f, object_hook=deserializeHook)
#         return content
# 
#     def write_content(self, content):
#         """
#         Write JSON file.
#         """
#         with open(self.path, 'w') as f:
#             json.dump(content, f, indent=2, sort_keys=True, cls=JSONSerializer)
# 
# Path: g_sorcery/exceptions.py
# class FileJSONError(GSorceryError):
#     pass
# 
# Path: g_sorcery/logger.py
# class Logger(object):
#     """
#     A simple logger object. Uses portage out facilities.
#     """
#     def __init__(self):
#         self.out = portage.output.EOutput()
# 
#     def error(self, message):
#         self.out.eerror(message)
# 
#     def info(self, message):
#         self.out.einfo(message)
# 
#     def warn(self, message):
#         self.out.ewarn(message)


import importlib
import os
import sys
from .compatibility import configparser
from .fileutils import FileJSON
from .exceptions import FileJSONError
from .logger import Logger
                     + name + ': ' + str(e) + '\n')
        return -1
    backend = get_backend(config['package'])

    if not backend:
        logger.error("backend initialization failed, exiting")
        return -1

    config_file = None
    for path in '.', '~', '/etc/g-sorcery':
        config_file = os.path.join(path, "g-sorcery.cfg")
        if (os.path.isfile(config_file)):
            break
        else:
            config_file = None

    if not config_file:
        logger.error('no global config file\n')
        return -1

    global_config = configparser.ConfigParser()
    global_config.read(config_file)

    return backend.instance(sys.argv[2:], config, global_config)


def get_backend(package):
    """
    Load backend by package name.
    """

# Path: g_sorcery/compatibility.py
# class TemporaryDirectory(object):
#     def __init__(self):
#     def __del__(self):
# 
# Path: g_sorcery/fileutils.py
# class FileJSON(FileJSONData):
#     """
#     Class for JSON files. Supports custom JSON serialization
#     provided by g_sorcery.serialization.
#     """
# 
#     def read_content(self):
#         """
#         Read JSON file.
#         """
#         content = {}
#         with open(self.path, 'r') as f:
#             content = json.load(f, object_hook=deserializeHook)
#         return content
# 
#     def write_content(self, content):
#         """
#         Write JSON file.
#         """
#         with open(self.path, 'w') as f:
#             json.dump(content, f, indent=2, sort_keys=True, cls=JSONSerializer)
# 
# Path: g_sorcery/exceptions.py
# class FileJSONError(GSorceryError):
#     pass
# 
# Path: g_sorcery/logger.py
# class Logger(object):
#     """
#     A simple logger object. Uses portage out facilities.
#     """
#     def __init__(self):
#         self.out = portage.output.EOutput()
# 
#     def error(self, message):
#         self.out.eerror(message)
# 
#     def info(self, message):
#         self.out.einfo(message)
# 
#     def warn(self, message):
#         self.out.ewarn(message)


# Path: g_sorcery/g_sorcery.py
import importlib
import os
import sys
from .compatibility import configparser
from .fileutils import FileJSON
from .exceptions import FileJSONError
from .logger import Logger

                     + name + ': ' + str(e) + '\n')
        return -1
    backend = get_backend(config['package'])

    if not backend:
        logger.error("backend initialization failed, exiting")
        return -1

    config_file = None
    for path in '.', '~', '/etc/g-sorcery':
        config_file = os.path.join(path, "g-sorcery.cfg")
        if (os.path.isfile(config_file)):
            break
        else:
            config_file = None

    if not config_file:
        logger.error('no global config file\n')
        return -1

    global_config = configparser.ConfigParser()
    global_config.read(config_file)

    return backend.instance(sys.argv[2:], config, global_config)


def get_backend(package):
    """
    Load backend by package name.
    """

    logger = Logger()