# 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/msgutil.py
# class DbProfilerJSONEncoder(json.JSONEncoder):
#     def default(self, o):
#         try:
#             iterable = iter(o)
#         except TypeError:
#             pass
#         else:
#             return list(iterable)
# 
#         if isinstance(o, datetime.datetime):
#             return o.isoformat()
#         elif isinstance(o, datetime.date):
#             return o.isoformat()
#         elif isinstance(o, decimal.Decimal):
#             return (str(o) for o in [o])
#         return super(DbProfilerJSONEncoder, self).default(o)
# 
# Path: hecatoncheir/msgutil.py
# class DbProfilerJSONEncoder(json.JSONEncoder):
#     def default(self, o):
# def jsonize(data):


import copy
import json
import sys
import dateutil.parser
from datetime import datetime
from hecatoncheir import logger as log
from hecatoncheir.msgutil import DbProfilerJSONEncoder
from hecatoncheir.msgutil import gettext as _
        assert isinstance(self.validation, list) or self.validation is None
        assert isinstance(self.comment, unicode) or self.comment is None

    def makedic(self):
        self.__assert()
        d = copy.deepcopy(self.__dict__)

        # FIXME:
        #   Backward compatibility stuff.
        #   Needs to be removed in the future.
        d['column_name'] = d['name']
        d['column_name_nls'] = d['name_nls']
        d['data_type'] = self.datatype
        del d['name']
        del d['name_nls']
        del d['datatype']

        d['most_freq_vals'] = []
        for v in self.most_freq_values:
            d['most_freq_vals'].append({'value': v[0], 'freq': v[1]})
        del d['most_freq_values']

        d['least_freq_vals'] = []
        for v in self.least_freq_values:
            d['least_freq_vals'].append({'value': v[0], 'freq': v[1]})
        del d['least_freq_values']

        return d

    def to_json(self):

# 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/msgutil.py
# class DbProfilerJSONEncoder(json.JSONEncoder):
#     def default(self, o):
#         try:
#             iterable = iter(o)
#         except TypeError:
#             pass
#         else:
#             return list(iterable)
# 
#         if isinstance(o, datetime.datetime):
#             return o.isoformat()
#         elif isinstance(o, datetime.date):
#             return o.isoformat()
#         elif isinstance(o, decimal.Decimal):
#             return (str(o) for o in [o])
#         return super(DbProfilerJSONEncoder, self).default(o)
# 
# Path: hecatoncheir/msgutil.py
# class DbProfilerJSONEncoder(json.JSONEncoder):
#     def default(self, o):
# def jsonize(data):


# Path: hecatoncheir/metadata.py
import copy
import json
import sys
import dateutil.parser
from datetime import datetime
from hecatoncheir import logger as log
from hecatoncheir.msgutil import DbProfilerJSONEncoder
from hecatoncheir.msgutil import gettext as _

        assert isinstance(self.validation, list) or self.validation is None
        assert isinstance(self.comment, unicode) or self.comment is None

    def makedic(self):
        self.__assert()
        d = copy.deepcopy(self.__dict__)

        # FIXME:
        #   Backward compatibility stuff.
        #   Needs to be removed in the future.
        d['column_name'] = d['name']
        d['column_name_nls'] = d['name_nls']
        d['data_type'] = self.datatype
        del d['name']
        del d['name_nls']
        del d['datatype']

        d['most_freq_vals'] = []
        for v in self.most_freq_values:
            d['most_freq_vals'].append({'value': v[0], 'freq': v[1]})
        del d['most_freq_values']

        d['least_freq_vals'] = []
        for v in self.least_freq_values:
            d['least_freq_vals'].append({'value': v[0], 'freq': v[1]})
        del d['least_freq_values']

        return d

    def to_json(self):

        return json.dumps(self.makedic(), cls=DbProfilerJSONEncoder)