# 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 _
        raise ValueError(_(u'Column "%s" not found on table "%s.%s".') %
                         (column_name, self.schema_name, self.table_name))

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

        # FIXME:
        #   Backward compatibility stuff.
        #   Needs to be removed in the future.
        d['columns'] = []
        for c in self.columns:
            d['columns'].append(c.makedic())
        del d['column_names']

        return d

    def from_json(self, j):
        dic = json.loads(j)
        self.table_name_nls = dic['table_name_nls']
        self.timestamp = dateutil.parser.parse(dic['timestamp'])
        self.row_count = long(dic['row_count'])
        for c in dic['columns']:
            cm = TableColumnMeta(c['column_name'])
            cm.from_json(json.dumps(c))
            self.columns.append(cm)
        self.comment = dic['comment']
        self.sample_rows = json.loads(dic.get('sample_rows', 'null'))

    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 _

        raise ValueError(_(u'Column "%s" not found on table "%s.%s".') %
                         (column_name, self.schema_name, self.table_name))

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

        # FIXME:
        #   Backward compatibility stuff.
        #   Needs to be removed in the future.
        d['columns'] = []
        for c in self.columns:
            d['columns'].append(c.makedic())
        del d['column_names']

        return d

    def from_json(self, j):
        dic = json.loads(j)
        self.table_name_nls = dic['table_name_nls']
        self.timestamp = dateutil.parser.parse(dic['timestamp'])
        self.row_count = long(dic['row_count'])
        for c in dic['columns']:
            cm = TableColumnMeta(c['column_name'])
            cm.from_json(json.dumps(c))
            self.columns.append(cm)
        self.comment = dic['comment']
        self.sample_rows = json.loads(dic.get('sample_rows', 'null'))

    def to_json(self):

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