コード例 #1
0
def ParseWikiPagePushInfo(page: pywikibot.Page):
    parsed_text = ParsePage(page)
    # If the score of a trivia is higher than this,
    # we'll try to show it only, without leading text.
    triviaSignificance = float(GetConfig("Wiki", "PushedTermsTTL", 180))
    # Distill text
    bareTitle = BareDisambigTitle(page.title())
    distilled = WikiPageDistiller.DistillHtml(parsed_text)
    info = WikiPagePushInfo(page.title(), page.full_url())
    if distilled.trivia != None:
        # Trivia only
        info.postText = distilled.trivia
        # Leading + trivia
        if distilled.triviaScore < triviaSignificance or not bareTitle in info.postText:
            info.postText = distilled.introduction + info.postText
    else:
        # Leading
        info.postText = distilled.introduction
    #elif len(distilled.introduction) < 50 :
    #info.post
    # Choose cover image
    info.postImageName, info.postImageUrl = GetCoverImage(page)
    return info