http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9455
Revision: 9455 Author: xqt Date: 2011-08-23 16:52:37 +0000 (Tue, 23 Aug 2011) Log Message: ----------- Create a new talk page if it does not exist
Modified Paths: -------------- trunk/pywikipedia/unusedfiles.py
Modified: trunk/pywikipedia/unusedfiles.py =================================================================== --- trunk/pywikipedia/unusedfiles.py 2011-08-21 18:31:37 UTC (rev 9454) +++ trunk/pywikipedia/unusedfiles.py 2011-08-23 16:52:37 UTC (rev 9455) @@ -13,6 +13,7 @@ # # (C) Leonardo Gregianin, 2007 # (C) Filnik, 2008 +# (c) xqt, 2011 # # Distributed under the terms of the MIT license. # @@ -61,15 +62,21 @@
def appendtext(page, apptext): global always - try: + if page.isRedirectPage(): + page = page.getRedirectTarget() + if not page.exists(): + if page.isTalkPage(): + text = u'' + else: + raise pywikibot.NoPage(u"Page '%s' does not exist" % page.title()) + else: text = page.get() - except pywikibot.IsRedirectPage: - return # Here you can go editing. If you find you do not # want to edit this page, just return - text += apptext; - if text != page.get(): - pywikibot.showDiff(page.get(),text) + oldtext = text + text += apptext + if text != oldtext: + pywikibot.showDiff(oldtext, text) if not always: choice = pywikibot.inputChoice( u'Do you want to accept these changes?', ['Yes', 'No', 'All'],
pywikipedia-svn@lists.wikimedia.org