# coding: utf-8"""This script gets a list of filelinks from BASEPAGE. They are images on Commonsthat have local description pages. Seehttp://hu.wikipedia.org/w/index.php?title=Szerkeszt%C5%91:Bin%C3%A1ris/Commonsk%C3%A9pek&oldid=11398781for format. This script will list the contents of the pages next to the titleso that you can overview which of them is to be deleted.For creating the list, see[[Wikipédia:SQL-lekérdezések#Commonsos képek helyi leírólappal]] on this wiki."""#(C) Bináris, 2012BASEPAGE=u'Szerkesztő:Bináris/Commonsképek'importreimportwikipediaaspywikibotsite=pywikibot.getSite()page=pywikibot.Page(site,BASEPAGE)text=page.get()pattern=re.compile(ur'#\[\[:(File:.*?)\]\]')counter=0forpinpattern.finditer(text):# p.group() -- the whole link to be replaced later# p.group(1) -- the filenamepic=pywikibot.Page(site,p.group(1))pywikibot.output(pic.title())counter+=1try:tic=pic.get().replace('\n','_')exceptpywikibot.NoPage:tic=u'Törölve?'# Deletedifnotlen(tic.replace(' ','').replace('_','')):tic=u'Üresnek látszik'#Emptypywikibot.output(tic)delimiter=u'==%d. szakasz==\n'%(counter//5+1)ifcounter%5==1else''text=text.replace(p.group(),delimiter+p.group()+' <nowiki>%s</nowiki>'%tic)page.put(text,u'commonslocaluncat.py: a helyi leírólapok listázása')