__init__.py 文件源码

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

项目:selecta 作者: vindolin 项目源码 文件源码
def __init__(self, list_item, show_hits, match=None):
        self.list_item = list_item

        if match is not None and match is not '' and show_hits is True:
            # highlight the matches
            hits = re.split('({match})'.format(match=re.escape(match)), self.list_item)
            parts = []
            for part in hits:
                if part == match:
                    parts.append(('pattern', part))
                else:
                    parts.append(part)

            text = urwid.AttrMap(
                urwid.Text(parts),
                'line',
                {'pattern': 'pattern_focus', None: 'line_focus'}
            )

        else:
            text = urwid.AttrMap(urwid.Text(self.list_item), 'line', 'line_focus')

        urwid.WidgetWrap.__init__(self, text)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号