http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10302
Revision: 10302
Author: xqt
Date: 2012-06-06 15:38:28 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
New option -async enables asynchron saving the page, request bug #3532278
update from rewrite r10301
Modified Paths:
--------------
trunk/pywikipedia/cosmetic_changes.py
Modified: trunk/pywikipedia/cosmetic_changes.py
===================================================================
--- trunk/pywikipedia/cosmetic_changes.py 2012-06-06 15:36:59 UTC (rev 10301)
+++ trunk/pywikipedia/cosmetic_changes.py 2012-06-06 15:38:28 UTC (rev 10302)
@@ -11,6 +11,8 @@
-always Don't prompt you for each replacement. Warning (see below)
has not to be confirmed. ATTENTION: Use this with care!
+-async Put page on queue to be saved to wiki asynchronously.
+
-summary:XYZ Set the summary message text for the edit to XYZ, bypassing
the predefined message texts with original and replacements
inserted.
@@ -804,12 +806,13 @@
return text
class CosmeticChangesBot:
- def __init__(self, generator, acceptall = False,
- comment=u'Robot: Cosmetic changes'):
+ def __init__(self, generator, acceptall=False,
+ comment=u'Robot: Cosmetic changes', async=False):
self.generator = generator
self.acceptall = acceptall
self.comment = comment
self.done = False
+ self.async = async
def treat(self, page):
try:
@@ -832,7 +835,10 @@
self.done = True
return
if self.acceptall or choice == 'y':
- page.put(changedText, comment=self.comment)
+ if self.async:
+ page.put_async(changedText, comment=self.comment)
+ else:
+ page.put(changedText, comment=self.comment)
else:
pywikibot.output('No changes were necessary in %s'
% page.title())
@@ -863,6 +869,7 @@
editSummary = ''
answer = 'y'
always = False
+ async = False
# This factory is responsible for processing command line arguments
# that are also used by other scripts and that determine on which pages
# to work on.
@@ -873,6 +880,8 @@
editSummary = arg[len('-summary:'):]
elif arg == '-always':
always = True
+ elif arg == '-async':
+ async = True
elif not genFactory.handleArg(arg):
pageTitle.append(arg)
@@ -895,7 +904,7 @@
if answer == 'y':
preloadingGen = pagegenerators.PreloadingGenerator(gen)
bot = CosmeticChangesBot(preloadingGen, acceptall=always,
- comment=editSummary)
+ comment=editSummary, async=async)
bot.run()
if __name__ == "__main__":
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10301
Revision: 10301
Author: xqt
Date: 2012-06-06 15:36:59 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
New option -async enables asynchron saving the page, request bug #3532278
Modified Paths:
--------------
branches/rewrite/scripts/cosmetic_changes.py
Modified: branches/rewrite/scripts/cosmetic_changes.py
===================================================================
--- branches/rewrite/scripts/cosmetic_changes.py 2012-06-06 15:05:45 UTC (rev 10300)
+++ branches/rewrite/scripts/cosmetic_changes.py 2012-06-06 15:36:59 UTC (rev 10301)
@@ -11,6 +11,8 @@
-always Don't prompt you for each replacement. Warning (see below)
has not to be confirmed. ATTENTION: Use this with care!
+-async Put page on queue to be saved to wiki asynchronously.
+
-summary:XYZ Set the summary message text for the edit to XYZ, bypassing
the predefined message texts with original and replacements
inserted.
@@ -655,12 +657,13 @@
return text
class CosmeticChangesBot:
- def __init__(self, generator, acceptall = False,
- comment=u'Robot: Cosmetic changes'):
+ def __init__(self, generator, acceptall=False,
+ comment=u'Robot: Cosmetic changes', async=False):
self.generator = generator
self.acceptall = acceptall
self.comment = comment
self.done = False
+ self.async = async
def treat(self, page):
try:
@@ -683,7 +686,8 @@
self.done = True
return
if self.acceptall or choice == 'y':
- page.put(changedText, comment=self.comment)
+ page.text = changedText
+ page.save(comment=self.comment, async=self.async)
else:
pywikibot.output('No changes were necessary in %s'
% page.title())
@@ -715,6 +719,7 @@
editSummary = ''
answer = 'y'
always = False
+ async = False
# This factory is responsible for processing command line arguments
# that are also used by other scripts and that determine on which pages
# to work on.
@@ -725,6 +730,8 @@
editSummary = arg[len('-summary:'):]
elif arg == '-always':
always = True
+ elif arg == '-async':
+ async = True
elif not genFactory.handleArg(arg):
pageTitle.append(arg)
@@ -747,7 +754,7 @@
if answer == 'y':
preloadingGen = pagegenerators.PreloadingGenerator(gen)
bot = CosmeticChangesBot(preloadingGen, acceptall=always,
- comment=editSummary)
+ comment=editSummary, async=async)
bot.run()
if __name__ == "__main__":
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10298
Revision: 10298
Author: xqt
Date: 2012-06-05 12:45:26 +0000 (Tue, 05 Jun 2012)
Log Message:
-----------
partially revert of r10291 since category default sortkey is fixed in r10297
Modified Paths:
--------------
branches/rewrite/scripts/cosmetic_changes.py
Modified: branches/rewrite/scripts/cosmetic_changes.py
===================================================================
--- branches/rewrite/scripts/cosmetic_changes.py 2012-06-05 12:41:01 UTC (rev 10297)
+++ branches/rewrite/scripts/cosmetic_changes.py 2012-06-05 12:45:26 UTC (rev 10298)
@@ -32,7 +32,7 @@
all of them, but be careful if you do.
"""
#
-# (C) xqt, 2009-2011
+# (C) xqt, 2009-2012
# (C) Pywikipedia bot team, 2006-2012
#
# Distributed under the terms of the MIT license.
@@ -141,7 +141,7 @@
if self.site.sitename()== u'commons:commons' and self.namespace == 6:
text = self.commonsfiledesc(text)
text = self.fixSelfInterwiki(text)
-## text = self.standardizePageFooter(text) # removes pipe links on categories
+ text = self.standardizePageFooter(text)
text = self.fixSyntaxSave(text)
## text = self.cleanUpLinks(text) #module object has no attribute url2unicode
text = self.cleanUpSectionHeaders(text)