コード例 #1
0
ファイル: wikimedia_sync.py プロジェクト: florentk/wikifundi
def getTemplateTitlesFromPage(siteSrc, nbPages, iTitles):
    (i, title) = iTitles

    p = Page(siteSrc, title)

    if (p.is_filepage()):
        # check if the file is in a specific file repository
        f = FilePage(siteSrc.image_repository(), title)
        if (f.exists()):
            # get template on page in specific file repository
            tplt = f.templates()
        else:
            # get templates from original site
            tplt = p.templates()
    else:
        # get templates
        tplt = p.templates()

    nbTplt = len(tplt)
    if (nbTplt > 0):
        log("%i/%i Process %s : %i templates found " %
            (i + 1, nbPages, title, nbTplt))
    else:
        log("%i/%i Process %s :no templates found " % (i + 1, nbPages, title))
    return mapTitle(tplt)