# Path: stampy/i18n.py
# def _(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     language = stampy.language
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[language])
#     return trad.ugettext(string)
# 
# Path: stampy/i18n.py
# def _L(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     loglanguage = stampy.loglanguage
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[loglanguage])
#     return trad.ugettext(string)


import logging
import stampy.stampy
from prettytable import from_db_cursor
from stampy.i18n import _
from stampy.i18n import _L
    # logger = logging.getLogger(__name__)
    string = (key, gid, )
    sql = "SELECT key,value FROM config WHERE key='%s' AND id='%s';" % string
    cur = stampy.stampy.dbsql(sql)
    value = cur.fetchone()

    try:
        # Get value from SQL query
        value = value[1]

    except:
        # Value didn't exist before, return default or False
        value = default

    return value


def setconfig(key, value, gid=0):
    """
    Sets a config parameter in database
    :param gid: group ID to check
    :param key: key to update
    :param value: value to store
    :return:
    """

    logger = logging.getLogger(__name__)
    if config(key=key, gid=gid):
        deleteconfig(key, gid=gid)
    sql = "INSERT INTO config VALUES('%s','%s', '%s');" % (key, value, gid)

# Path: stampy/i18n.py
# def _(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     language = stampy.language
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[language])
#     return trad.ugettext(string)
# 
# Path: stampy/i18n.py
# def _L(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     loglanguage = stampy.loglanguage
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[loglanguage])
#     return trad.ugettext(string)


# Path: stampy/plugin/config.py
import logging
import stampy.stampy
from prettytable import from_db_cursor
from stampy.i18n import _
from stampy.i18n import _L

    # logger = logging.getLogger(__name__)
    string = (key, gid, )
    sql = "SELECT key,value FROM config WHERE key='%s' AND id='%s';" % string
    cur = stampy.stampy.dbsql(sql)
    value = cur.fetchone()

    try:
        # Get value from SQL query
        value = value[1]

    except:
        # Value didn't exist before, return default or False
        value = default

    return value


def setconfig(key, value, gid=0):
    """
    Sets a config parameter in database
    :param gid: group ID to check
    :param key: key to update
    :param value: value to store
    :return:
    """

    logger = logging.getLogger(__name__)
    if config(key=key, gid=gid):
        deleteconfig(key, gid=gid)
    sql = "INSERT INTO config VALUES('%s','%s', '%s');" % (key, value, gid)

    logger.debug(msg=_L("setconfig: %s=%s for id %s") % (key, value, gid))