Gebruiker:Bitbotje/wdlabelupdate.py

Uit Wikipedia, de vrije encyclopedie
Naar navigatie springen Naar zoeken springen
import pwb
import pywikibot
from pywikibot.backports import Tuple
from scripts import category

def main(*args: Tuple[str, ...]) -> None:
    inputFile = open('pagelist.txt', 'r')
    site = pywikibot.Site()
    for line in inputFile:
        page = pywikibot.Page(site, line)
        try:
            item = pywikibot.ItemPage.fromPage(page)
            item.get()
            item.editLabels(labels={'nl': page.title(with_ns=True)}, summary='Update [nl] label')
        except pywikibot.exceptions.NoPageError:
            pass

    inputFile.close()
    print('Done.')


if __name__ == '__main__':
    main()