From e3b70b12caa29ccb147f657fda5d4a5086685cd1 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 26 Aug 2010 22:24:38 +0000 Subject: [PATCH] Trimmed code git-svn-id: https://svn.toolserver.org/svnroot/andrew@3 440749c3-aac8-6324-963f-c2cb0199677f --- afcfix.py | 69 --------------------------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/afcfix.py b/afcfix.py index 9b1ffd0..e554c7f 100644 --- a/afcfix.py +++ b/afcfix.py @@ -58,24 +58,6 @@ class BasicBot: self.treat(page) def treat(self, page): - """ - Loads the given page, does some changes, and saves it. - - text = self.load(page) - if not text: - return - - ################################################################ - # NOTE: Here you can modify the text in whatever way you want. # - ################################################################ - - # If you find out that you do not want to edit this page, just return. - # Example: This puts the text 'Test' at the beginning of the page. - text = 'Test ' + text - - if not self.save(text, page, self.summary): - pywikibot.output(u'Page %s not saved.' % page.aslink()) """ - namespace_pg = page.namespace() tmp = "" if namespace_pg != 5: @@ -102,57 +84,6 @@ class BasicBot: if not self.doNotMove: print "I would have moved " + tg + " to: " + tmp - def load(self, page): - """ - Loads the given page, does some changes, and saves it. - """ - try: - # Load the page - text = page.get() - except pywikibot.NoPage: - pywikibot.output(u"Page %s does not exist; skipping." - % page.aslink()) - except pywikibot.IsRedirectPage: - pywikibot.output(u"Page %s is a redirect; skipping." - % page.aslink()) - else: - return text - return None - - def save(self, text, page, comment, minorEdit=True, botflag=True): - # only save if something was changed - if text != page.get(): - # Show the title of the page we're working on. - # Highlight the title in purple. - pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" - % page.title()) - # show what was changed - pywikibot.showDiff(page.get(), text) - pywikibot.output(u'Comment: %s' %comment) - if not self.dry: - choice = pywikibot.inputChoice( - u'Do you want to accept these changes?', - ['Yes', 'No'], ['y', 'N'], 'N') - if choice == 'y': - try: - # Save the page - page.put(text, comment=comment, - minorEdit=minorEdit, botflag=botflag) - except pywikibot.LockedPage: - pywikibot.output(u"Page %s is locked; skipping." - % page.aslink()) - except pywikibot.EditConflict: - pywikibot.output( - u'Skipping %s because of edit conflict' - % (page.title())) - except pywikibot.SpamfilterError, error: - pywikibot.output( -u'Cannot change %s because of spam blacklist entry %s' - % (page.title(), error.url)) - else: - return True - return False - def main(): # This factory is responsible for processing command line arguments # that are also used by other scripts and that determine on which pages -- 2.11.4.GIT