# Path: elodie/compatability.py
# def _bytes(string):
#     if constants.python_version == 3:
#         return bytes(string, 'utf8')
#     else:
#         return bytes(string)
# 
# Path: elodie/config.py
# def load_config_for_plugin(name):
#     # Plugins store data using Plugin%PluginName% format.
#     key = 'Plugin{}'.format(name)
#     config = load_config()
# 
#     if key in config:
#         return config[key]
# 
#     return {}
# 
# def load_plugin_config():
#     config = load_config()
# 
#     # If plugins are defined in the config we return them as a list
#     # Else we return an empty list
#     if 'Plugins' in config and 'plugins' in config['Plugins']:
#         return config['Plugins']['plugins'].split(',')
# 
#     return []
# 
# Path: elodie/constants.py

# 
# Path: elodie/log.py
# def all(message):
# def info(message):
# def info_json(payload):
# def progress(message='.', new_line=False):
# def warn(message):
# def warn_json(payload):
# def error(message):
# def error_json(payload):
# def _print_debug(string):
# def _print(s):


from builtins import object
from json import dumps, loads
from importlib import import_module
from os.path import dirname, dirname, isdir, isfile
from os import mkdir
from sys import exc_info
from traceback import format_exc
from elodie.compatability import _bytes
from elodie.config import load_config_for_plugin, load_plugin_config
from elodie.constants import application_directory
from elodie import log
import io

    def log(self, msg):
        # Writes an info log not shown unless being run in --debug mode.
        log.info(dumps(
            {self.__name__: msg}
        ))

    def display(self, msg):
        # Writes a log for all modes and will be displayed.
        log.all(dumps(
            {self.__name__: msg}
        ))

class PluginDb(object):
    """A database module which provides a simple key/value database.
       The database is a JSON file located at %application_directory%/plugins/%pluginname.lower()%.json
    """
    def __init__(self, plugin_name):
        self.db_file = '{}/plugins/{}.json'.format(
            application_directory,
            plugin_name.lower()
        )

        # If the plugin db directory does not exist, create it
        if(not isdir(dirname(self.db_file))):
            mkdir(dirname(self.db_file))

        # If the db file does not exist we initialize it
        if(not isfile(self.db_file)):
            with io.open(self.db_file, 'wb') as f:

# Path: elodie/compatability.py
# def _bytes(string):
#     if constants.python_version == 3:
#         return bytes(string, 'utf8')
#     else:
#         return bytes(string)
# 
# Path: elodie/config.py
# def load_config_for_plugin(name):
#     # Plugins store data using Plugin%PluginName% format.
#     key = 'Plugin{}'.format(name)
#     config = load_config()
# 
#     if key in config:
#         return config[key]
# 
#     return {}
# 
# def load_plugin_config():
#     config = load_config()
# 
#     # If plugins are defined in the config we return them as a list
#     # Else we return an empty list
#     if 'Plugins' in config and 'plugins' in config['Plugins']:
#         return config['Plugins']['plugins'].split(',')
# 
#     return []
# 
# Path: elodie/constants.py

# 
# Path: elodie/log.py
# def all(message):
# def info(message):
# def info_json(payload):
# def progress(message='.', new_line=False):
# def warn(message):
# def warn_json(payload):
# def error(message):
# def error_json(payload):
# def _print_debug(string):
# def _print(s):


# Path: elodie/plugins/plugins.py
from builtins import object
from json import dumps, loads
from importlib import import_module
from os.path import dirname, dirname, isdir, isfile
from os import mkdir
from sys import exc_info
from traceback import format_exc
from elodie.compatability import _bytes
from elodie.config import load_config_for_plugin, load_plugin_config
from elodie.constants import application_directory
from elodie import log
import io


    def log(self, msg):
        # Writes an info log not shown unless being run in --debug mode.
        log.info(dumps(
            {self.__name__: msg}
        ))

    def display(self, msg):
        # Writes a log for all modes and will be displayed.
        log.all(dumps(
            {self.__name__: msg}
        ))

class PluginDb(object):
    """A database module which provides a simple key/value database.
       The database is a JSON file located at %application_directory%/plugins/%pluginname.lower()%.json
    """
    def __init__(self, plugin_name):
        self.db_file = '{}/plugins/{}.json'.format(
            application_directory,
            plugin_name.lower()
        )

        # If the plugin db directory does not exist, create it
        if(not isdir(dirname(self.db_file))):
            mkdir(dirname(self.db_file))

        # If the db file does not exist we initialize it
        if(not isfile(self.db_file)):
            with io.open(self.db_file, 'wb') as f:

                f.write(_bytes(dumps({})))