# -*- 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.importpywikibotfrompagegeneratorsimportReferringPageGeneratorWHERETOPUT=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()fortplinhasTemplates:reftpl=pywikibot.Page(site,'template:'+tpl)i=0forpageinReferringPageGenerator(reftpl,onlyTemplateInclusion=True):i+=1pywikibot.output('%d. %s'%(i,page.title()))hasSet.add(page)print(len(hasSet))fortplinnoTemplates:reftpl=pywikibot.Page(site,'template:'+tpl)i=0forpageinReferringPageGenerator(reftpl,onlyTemplateInclusion=True):i+=1pywikibot.output('%d. %s'%(i,page.title()))hasNotSet.add(page)print(len(hasNotSet))i=0text=''forpageinhasSet-hasNotSet:i+=1pywikibot.output(u'Result: %d. %s'%(i,page.title()))text+=u'# [[:%s]]\n'%page.title()target=pywikibot.Page(site,WHERETOPUT)target.put(text)