示例#1
0
文件: evaluation.py 项目: wuub/kodiak
def get_body_content(
    *,
    body_type: BodyText,
    strip_html_comments: bool,
    cut_body_before: str,
    cut_body_after: str,
    pull_request: PullRequest,
) -> str:
    if body_type is BodyText.markdown:
        body = pull_request.body
        if cut_body_before != "":
            start_index = body.find(cut_body_before)
            if start_index != -1:
                body = body[start_index:]
        if cut_body_after != "":
            end_index = body.find(cut_body_after)
            if end_index != -1:
                body = body[:end_index + len(cut_body_after)]
        if strip_html_comments:
            return strip_html_comments_from_markdown(body)
        return body
    if body_type is BodyText.plain_text:
        return pull_request.bodyText
    if body_type is BodyText.html:
        return pull_request.bodyHTML
    assert_never(body_type)
示例#2
0
def get_body_content(body_type: BodyText, strip_html_comments: bool,
                     pull_request: PullRequest) -> str:
    if body_type == BodyText.markdown:
        body = pull_request.body
        if strip_html_comments:
            return strip_html_comments_from_markdown(body)
        return body
    if body_type == BodyText.plain_text:
        return pull_request.bodyText
    if body_type == BodyText.html:
        return pull_request.bodyHTML
    raise Exception(f"Unknown body_type: {body_type}")
示例#3
0
def test_strip_html_comments_from_markdown(original: str,
                                           stripped: str) -> None:
    assert strip_html_comments_from_markdown(original) == stripped