# Path: turbo/log.py
# PY3 = sys.version_info >= (3,)
# def _init_file_logger(logger, level, log_path, log_size, log_count):
# def _init_stream_logger(logger, level=None):
# def _module_logger(path):
# def getLogger(currfile=None, level=None, log_path=None, log_size=500 * 1024 * 1024, log_count=3):
# 
# Path: turbo/util.py
# PY3 = sys.version_info >= (3,)
# _UTF8_TYPES = (bytes, type(None))
# _BASESTRING_TYPES = (basestring_type, type(None))
# def to_list_str(value, encode=None):
# def to_dict_str(origin_value, encode=None):
# def default_encode(v):
# def to_str(v, encode=None):
# def format_time(dt):
# def to_objectid(objid):
# def json_encode(data, **kwargs):
# def json_decode(data, **kwargs):
# def to_int(value, default=None):
# def to_float(value, default=None):
# def to_datetime(t, micro=False):
# def to_time(t, micro=False):
#     def __init__(self, module):
#     def __getattr__(self, name):
# def get_base_dir(currfile, dir_level_num=3):
# def join_sys_path(currfile, dir_level_num=3):
# def import_object(name, package_space=None):
# def camel_to_underscore(name):
# def remove_folder(path, foldername):
# def remove_file(path, filename):
# def remove_extension(path, extension):
# def build_index(model_list):
# def utf8(value):
# def to_basestring(value):
# def get_func_name(func):
# class Escape(object):


from collections import defaultdict
from datetime import datetime
from bson.objectid import ObjectId
from turbo.log import model_log
from turbo.util import escape as _es, import_object
import functools
import time
        if _mongo_db_mapping is None:
            raise Exception("db mapping is invalid")
        # databases
        db = _mongo_db_mapping['db']
        # databases file
        db_file = _mongo_db_mapping['db_file']

        # databse name
        if db_name not in db or db.get(db_name, None) is None:
            raise Exception('%s is invalid databse' % db_name)

        # collection name
        if not self.name:
            raise Exception('%s is invalid collection name' % self.name)

        # collection field
        if not self.field or not isinstance(self.field, dict):
            raise Exception('%s is invalid collection field' % self.field)

        # collect as private variable
        collect = getattr(db.get(db_name, object), self.name, None)
        if collect is None:
            raise Exception('%s is invalid collection' % self.name)

        # replace pymongo collect with custome connect
        _collect = MongoTurboConnect(self, collect)

        # gridfs as private variable
        _gridfs = db_file.get(db_name, None)
        if _gridfs is None:

# Path: turbo/log.py
# PY3 = sys.version_info >= (3,)
# def _init_file_logger(logger, level, log_path, log_size, log_count):
# def _init_stream_logger(logger, level=None):
# def _module_logger(path):
# def getLogger(currfile=None, level=None, log_path=None, log_size=500 * 1024 * 1024, log_count=3):
# 
# Path: turbo/util.py
# PY3 = sys.version_info >= (3,)
# _UTF8_TYPES = (bytes, type(None))
# _BASESTRING_TYPES = (basestring_type, type(None))
# def to_list_str(value, encode=None):
# def to_dict_str(origin_value, encode=None):
# def default_encode(v):
# def to_str(v, encode=None):
# def format_time(dt):
# def to_objectid(objid):
# def json_encode(data, **kwargs):
# def json_decode(data, **kwargs):
# def to_int(value, default=None):
# def to_float(value, default=None):
# def to_datetime(t, micro=False):
# def to_time(t, micro=False):
#     def __init__(self, module):
#     def __getattr__(self, name):
# def get_base_dir(currfile, dir_level_num=3):
# def join_sys_path(currfile, dir_level_num=3):
# def import_object(name, package_space=None):
# def camel_to_underscore(name):
# def remove_folder(path, foldername):
# def remove_file(path, filename):
# def remove_extension(path, extension):
# def build_index(model_list):
# def utf8(value):
# def to_basestring(value):
# def get_func_name(func):
# class Escape(object):


# Path: turbo/mongo_model.py
from collections import defaultdict
from datetime import datetime
from bson.objectid import ObjectId
from turbo.log import model_log
from turbo.util import escape as _es, import_object
import functools
import time

        if _mongo_db_mapping is None:
            raise Exception("db mapping is invalid")
        # databases
        db = _mongo_db_mapping['db']
        # databases file
        db_file = _mongo_db_mapping['db_file']

        # databse name
        if db_name not in db or db.get(db_name, None) is None:
            raise Exception('%s is invalid databse' % db_name)

        # collection name
        if not self.name:
            raise Exception('%s is invalid collection name' % self.name)

        # collection field
        if not self.field or not isinstance(self.field, dict):
            raise Exception('%s is invalid collection field' % self.field)

        # collect as private variable
        collect = getattr(db.get(db_name, object), self.name, None)
        if collect is None:
            raise Exception('%s is invalid collection' % self.name)

        # replace pymongo collect with custome connect
        _collect = MongoTurboConnect(self, collect)

        # gridfs as private variable
        _gridfs = db_file.get(db_name, None)
        if _gridfs is None:

            model_log.info('%s is invalid gridfs' % _gridfs)