dbconnector.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:sonic-snmpagent 作者: Azure 项目源码 文件源码
def keys(self, pattern='*'):
        """Emulate keys."""
        import fnmatch
        import re

        # making sure the pattern is unicode/str.
        try:
            pattern = pattern.decode('utf-8')
            # This throws an AttributeError in python 3, or an
            # UnicodeEncodeError in python 2
        except (AttributeError, UnicodeEncodeError):
            pass

        # Make regex out of glob styled pattern.
        regex = fnmatch.translate(pattern)
        regex = re.compile(regex)

        # Find every key that matches the pattern
        return [key for key in self.redis.keys() if regex.match(key.decode('utf-8'))]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号