netcfg.py 文件源码

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

项目:iosxr-ansible 作者: ios-xr 项目源码 文件源码
def search(self, regexp, path=None):
        regex = re.compile(r'^%s' % regexp, re.M)

        if path:
            parent = self.get(path)
            if not parent or not parent.children:
                return
            children = [c.text for c in parent.children]
            data = '\n'.join(children)
        else:
            data = str(self)

        match = regex.search(data)
        if match:
            if match.groups():
                values = match.groupdict().values()
                groups = list(set(match.groups()).difference(values))
                return (groups, match.groupdict())
            else:
                return match.group()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号