annotator.py 文件源码

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

项目:PyTest 作者: kaste 项目源码 文件源码
def build_phantoms(view, errs, formatter):
    phantoms = []

    show_focus_links = len(errs) > 1
    for tbck in errs:
        line = tbck['line']
        text = tbck['text']
        testcase = tbck.get('testcase')

        if text == '':
            continue

        pt = view.text_point(line - 1, 0)
        indentation = get_indentation_at(view, pt)
        text = formatter.format_text(text, indentation)

        if show_focus_links and testcase:
            focus_link = (
                ' <a href="focus:{}">focus test</a>'.format(testcase))

            lines = text.split('<br />')
            text = '<br />'.join([lines[0] + focus_link] + lines[1:])

        phantoms.append(sublime.Phantom(
            sublime.Region(pt, view.line(pt).b),
            ('<body id=inline-error>' + STYLESHEET +
                '<div class="error">' +
                '<span class="message">' + text + '</span>' +
                '</div>' +
                '</body>'),
            sublime.LAYOUT_BELOW, _on_navigate))

    return phantoms
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号