Szerkesztő:BinBot/logowithoutOTRS.py
Megjelenés
- Wikipédia:Botgazdák üzenőfala/Archív 20#Logók kigyűjtése
- Wikipédia:Karbantartóműhely/Logók OTRS sablon nélkül
# -*- coding: utf-8 -*-
"""
Gathers pages which have one of the templates listed in hasTemplates,
and have none of those listed in noTemplates.
"""
#
# (C) Bináris, 2015
#
# Distributed under the terms of the MIT license.
import pywikibot
from pagegenerators import ReferringPageGenerator
WHERETOPUT = u'user:BinBot/logóteszt'
hasTemplates = [u'logó']
# noTemplates = ['OTRS', 'OTRS-licenc', 'PermissionOTRS', 'Otrs']
noTemplates = ['OTRS-licenc'] # This one is enough in this case as the others redirect to it.
hasSet = set()
hasNotSet = set()
site = pywikibot.getSite()
for tpl in hasTemplates:
reftpl = pywikibot.Page(site, 'template:' + tpl)
i = 0
for page in ReferringPageGenerator(reftpl,
onlyTemplateInclusion=True):
i += 1
pywikibot.output('%d. %s' % (i, page.title()))
hasSet.add(page)
print(len(hasSet))
for tpl in noTemplates:
reftpl = pywikibot.Page(site, 'template:' + tpl)
i = 0
for page in ReferringPageGenerator(reftpl,
onlyTemplateInclusion=True):
i += 1
pywikibot.output('%d. %s' % (i, page.title()))
hasNotSet.add(page)
print(len(hasNotSet))
i = 0
text = ''
for page in hasSet - hasNotSet:
i += 1
pywikibot.output(u'Result: %d. %s' % (i, page.title()))
text += u'# [[:%s]]\n' % page.title()
target = pywikibot.Page(site, WHERETOPUT)
target.put(text)