# Path: hecatoncheir/logger.py
# def to_unicode(s):
# def str2unicode(s):
# def setup():
# def ts():
# def trace(msg):
# def debug(msg):
# def info(msg):
# def info_cont(msg):
# def info_end(msg):
# def warning(msg):
# def error(msg, detail=None, query=None):
# def dump_datetime_default(o):
# def dump(msg, obj):
# 
# Path: hecatoncheir/exception.py
# class DriverError(Exception):
#     source = None
# 
#     def __init__(self, value, source=None):
#         self.value = value
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# class QueryError(Exception):
#     source = None
#     query = None
# 
#     def __init__(self, value, query, source=None):
#         self.value = value
#         self.query = query
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# class ValidationError(Exception):
#     source = None
# 
#     def __init__(self, value, rule, params=None, source=None):
#         self.value = value
#         self.rule = rule
#         self.params = params
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# Path: hecatoncheir/msgutil.py
# class DbProfilerJSONEncoder(json.JSONEncoder):
#     def default(self, o):
# def jsonize(data):


from hecatoncheir import logger as log
from hecatoncheir.exception import (DriverError, QueryError, ValidationError)
from hecatoncheir.msgutil import gettext as _
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-



# -------------------------------------------
# eval validator, used by sql validator
# -------------------------------------------
def validate_eval(kv, p):
    """Validate a format with column values

    Args:
      kv (dict): column name as key, and value
      p (str): format to be evaluated

    Returns:
      bool: True on success, otherwise False
    """
    try:
        s = p.format(**kv)
    except KeyError as e:
        raise ValidationError(
            _("Parameter error: ") + "`%s' %s" % (p, kv),
            rule=p, params=kv)

    try:
        return eval(s)
    except SyntaxError as e:
        raise ValidationError(

# Path: hecatoncheir/logger.py
# def to_unicode(s):
# def str2unicode(s):
# def setup():
# def ts():
# def trace(msg):
# def debug(msg):
# def info(msg):
# def info_cont(msg):
# def info_end(msg):
# def warning(msg):
# def error(msg, detail=None, query=None):
# def dump_datetime_default(o):
# def dump(msg, obj):
# 
# Path: hecatoncheir/exception.py
# class DriverError(Exception):
#     source = None
# 
#     def __init__(self, value, source=None):
#         self.value = value
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# class QueryError(Exception):
#     source = None
#     query = None
# 
#     def __init__(self, value, query, source=None):
#         self.value = value
#         self.query = query
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# class ValidationError(Exception):
#     source = None
# 
#     def __init__(self, value, rule, params=None, source=None):
#         self.value = value
#         self.rule = rule
#         self.params = params
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# Path: hecatoncheir/msgutil.py
# class DbProfilerJSONEncoder(json.JSONEncoder):
#     def default(self, o):
# def jsonize(data):


# Path: hecatoncheir/validator/SQLValidator.py
from hecatoncheir import logger as log
from hecatoncheir.exception import (DriverError, QueryError, ValidationError)
from hecatoncheir.msgutil import gettext as _

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-



# -------------------------------------------
# eval validator, used by sql validator
# -------------------------------------------
def validate_eval(kv, p):
    """Validate a format with column values

    Args:
      kv (dict): column name as key, and value
      p (str): format to be evaluated

    Returns:
      bool: True on success, otherwise False
    """
    try:
        s = p.format(**kv)
    except KeyError as e:
        raise ValidationError(
            _("Parameter error: ") + "`%s' %s" % (p, kv),
            rule=p, params=kv)

    try:
        return eval(s)
    except SyntaxError as e:
        raise ValidationError(

            _("Syntax error: ") + "`%s'" % s,