示例#1
0
文件: redis.py 项目: noQ/PyRTS
 def parser_class(self):
     cls = self.options.get('PARSER_CLASS', None)
     if cls is None:
         return DefaultParser
     mod_path, cls_name = cls.rsplit('.', 1)
     try:
         mod = import_module(mod_path)
         parser_class = getattr(mod, cls_name)
     except (AttributeError, ImportError):
         raise Exception("Could not find parser class '%s'" % parser_class)
     return parser_class
示例#2
0
文件: base.py 项目: noQ/PyRTS
def get_key_func(key_func):
    """
    Function to decide which key function to use.

    Defaults to ``default_key_func``.
    """
    if key_func is not None:
        if callable(key_func):
            return key_func
        else:
            key_func_module_path, key_func_name = key_func.rsplit('.', 1)
            key_func_module = import_module(key_func_module_path)
            return getattr(key_func_module, key_func_name)
    return default_key_func