# Path: library/config/database.py

# 
# Path: library/utils/dict.py
# def dot2_(data):
#     
#     '''
#     用于处理字典的key中带有.转化为特定字符，如果写入mongodb，报错
#     :parm:
#         data:需要处理的字典
#     '''
#     
#     new_data = {}
#     if isinstance(data, dict) :
#         for key, vaule in data.items() :
#             key = key.replace('.' , fmt)
#             if isinstance(vaule, dict) :
#                 new_data[key] = dot2_(vaule)
#             else :
#                 new_data[key] = vaule
#     return new_data
# 
# def _2dot(data):   
#      
#     '''
#     用于处理字典的key中带有特定字符转化为.，如果写入mongodb，报错
#     :parm:
#         data:需要处理的字典
#     '''
#     
#     new_data = {}
#     if isinstance(data, dict) :
#         for key, vaule in data.items() :
#             key = key.replace(fmt , '.')
#             if isinstance(vaule, dict) :
#                 new_data[key] = _2dot(vaule)
#             else :
#                 new_data[key] = vaule
#     return new_data


import time, logging, pymongo
from bson.objectid import ObjectId
from library.config.database import mongo_config
from library.utils.dict import dot2_, _2dot
            self.logger.error(self.log_prefix + ' 插入数据到集合' + collect_name + '失败，原因：' + str(e))
            return (False, '插入数据失败，' + str(e))
            

    def _handler_condition(self, condition_dict):
        '''
        在查询或更新数据时，对查询条件进行处理
        '''
        condition_dict = dot2_(condition_dict)
        for k, v in condition_dict.items() :
            if k == '_id' :
                # 把_id的值进行转化
                if isinstance(v, str) :
                    try :
                        v = int(v)
                    except :
                        v = ObjectId(v)
                                
                    condition_dict[k] = v
                
        return condition_dict


    def _handler_result(self, query_list, get_field=[]):
        '''
        在查询数据时，处理查询结果
        '''

        result_list = []
        for result_dict in query_list :

# Path: library/config/database.py

# 
# Path: library/utils/dict.py
# def dot2_(data):
#     
#     '''
#     用于处理字典的key中带有.转化为特定字符，如果写入mongodb，报错
#     :parm:
#         data:需要处理的字典
#     '''
#     
#     new_data = {}
#     if isinstance(data, dict) :
#         for key, vaule in data.items() :
#             key = key.replace('.' , fmt)
#             if isinstance(vaule, dict) :
#                 new_data[key] = dot2_(vaule)
#             else :
#                 new_data[key] = vaule
#     return new_data
# 
# def _2dot(data):   
#      
#     '''
#     用于处理字典的key中带有特定字符转化为.，如果写入mongodb，报错
#     :parm:
#         data:需要处理的字典
#     '''
#     
#     new_data = {}
#     if isinstance(data, dict) :
#         for key, vaule in data.items() :
#             key = key.replace(fmt , '.')
#             if isinstance(vaule, dict) :
#                 new_data[key] = _2dot(vaule)
#             else :
#                 new_data[key] = vaule
#     return new_data


# Path: library/storage/database/mongo.py
import time, logging, pymongo
from bson.objectid import ObjectId
from library.config.database import mongo_config
from library.utils.dict import dot2_, _2dot

            self.logger.error(self.log_prefix + ' 插入数据到集合' + collect_name + '失败，原因：' + str(e))
            return (False, '插入数据失败，' + str(e))
            

    def _handler_condition(self, condition_dict):
        '''
        在查询或更新数据时，对查询条件进行处理
        '''
        condition_dict = dot2_(condition_dict)
        for k, v in condition_dict.items() :
            if k == '_id' :
                # 把_id的值进行转化
                if isinstance(v, str) :
                    try :
                        v = int(v)
                    except :
                        v = ObjectId(v)
                                
                    condition_dict[k] = v
                
        return condition_dict


    def _handler_result(self, query_list, get_field=[]):
        '''
        在查询数据时，处理查询结果
        '''

        result_list = []
        for result_dict in query_list :

            result_dict = _2dot(result_dict)   