http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10706
Revision: 10706 Author: huji Date: 2012-11-11 17:16:34 +0000 (Sun, 11 Nov 2012) Log Message: ----------- unusedfile breaks if the file is deleted (hence a try .. except). Also, updating its Persian message and adding start paramter. Credit goes to mahdiz
Modified Paths: -------------- trunk/pywikipedia/unusedfiles.py
Modified: trunk/pywikipedia/unusedfiles.py =================================================================== --- trunk/pywikipedia/unusedfiles.py 2012-11-11 15:11:18 UTC (rev 10705) +++ trunk/pywikipedia/unusedfiles.py 2012-11-11 17:16:34 UTC (rev 10706) @@ -46,7 +46,7 @@ } template_to_the_user = { 'en': u'\n\n{{img-sem-uso|%(title)s}}', - 'fa': u'\n\n{{اخطار به کاربر برای تصاویر بدون استفاده|%(title)s}}--~~~~', + 'fa': u'\n\n{{جا:اخطار به کاربر برای تصاویر بدون استفاده|%(title)s}}--~~~~', 'it': u'\n\n{{Utente:Filbot/Immagine orfana}}', } except_text = { @@ -93,6 +93,8 @@ for arg in pywikibot.handleArgs(): if arg == '-always': always = True + if arg == '-start': + start = True
mysite = pywikibot.getSite() # If anything needs to be prepared, you can do it here @@ -114,12 +116,15 @@ pywikibot.output(u"%s done already" % page.title(asLink=True)) continue - appendtext(page, u"\n\n"+template_image) - uploader = page.getFileVersionHistory().pop()[1] - usertalkname = u'User Talk:%s' % uploader - usertalkpage = pywikibot.Page(mysite, usertalkname) - msg2uploader = template_user % {'title': page.title()} - appendtext(usertalkpage, msg2uploader) + try: + appendtext(page, u"\n\n"+template_image) + uploader = page.getFileVersionHistory().pop()[1] + usertalkname = u'User Talk:%s' % uploader + usertalkpage = pywikibot.Page(mysite, usertalkname) + msg2uploader = template_user % {'title': page.title()} + appendtext(usertalkpage, msg2uploader) + except: + continue
if __name__ == "__main__": try: