# Path: library/config/database.py

# 
# Path: library/utils/type_conv.py
# def bytes2string(data, encoding='utf-8'):
#     
#     '''
#     简单粗暴地把bytes字符串转换为str字符串
#     data必须是简单bytes格式
#     如果复杂，转化可能成功，但后续处理出差几率很大，请使用obj2string方法
#     :parm
#         data：字符串
#         encoding：编码
#     '''
#         
#     if isinstance(data, str):
#         return data
#     
#     try :
#         data = data.decode(encoding)
#         # result.decode('ascii') bytes解码会得到str
#     except :
#         new_data = obj2string(data, encoding=encoding)
#         if new_data[0] :
#             data = new_data[1]
#         
#     return data


import pickle, redis, logging
from library.config.database import redis_config
from library.utils.type_conv import bytes2string
'''
参考文献https://pypi.python.org/pypi/redis/2.10.5
redis模块可实现redis的单机版、sentinel模式，支持Publish/Subscribe、pineline、线程等功能
'''




class Op_Redis():
    '''
    连接并操作redis
    '''
    def __init__(self, dest=None):
        self.logger = logging.getLogger("database")
        

# Path: library/config/database.py

# 
# Path: library/utils/type_conv.py
# def bytes2string(data, encoding='utf-8'):
#     
#     '''
#     简单粗暴地把bytes字符串转换为str字符串
#     data必须是简单bytes格式
#     如果复杂，转化可能成功，但后续处理出差几率很大，请使用obj2string方法
#     :parm
#         data：字符串
#         encoding：编码
#     '''
#         
#     if isinstance(data, str):
#         return data
#     
#     try :
#         data = data.decode(encoding)
#         # result.decode('ascii') bytes解码会得到str
#     except :
#         new_data = obj2string(data, encoding=encoding)
#         if new_data[0] :
#             data = new_data[1]
#         
#     return data


# Path: library/storage/database/redis_api.py
import pickle, redis, logging
from library.config.database import redis_config
from library.utils.type_conv import bytes2string

'''
参考文献https://pypi.python.org/pypi/redis/2.10.5
redis模块可实现redis的单机版、sentinel模式，支持Publish/Subscribe、pineline、线程等功能
'''




class Op_Redis():
    '''
    连接并操作redis
    '''
    def __init__(self, dest=None):
        self.logger = logging.getLogger("database")
        

        config = redis_config