http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10354
Revision: 10354 Author: drtrigon Date: 2012-06-13 10:26:56 +0000 (Wed, 13 Jun 2012) Log Message: ----------- follow-up; in order to r10353 replace '-dry' by '-simulate'
Modified Paths: -------------- trunk/pywikipedia/basic.py trunk/pywikipedia/blockreview.py trunk/pywikipedia/djvutext.py trunk/pywikipedia/featured.py trunk/pywikipedia/pagefromfile.py trunk/pywikipedia/piper.py
Modified: trunk/pywikipedia/basic.py =================================================================== --- trunk/pywikipedia/basic.py 2012-06-13 09:10:13 UTC (rev 10353) +++ trunk/pywikipedia/basic.py 2012-06-13 10:26:56 UTC (rev 10354) @@ -9,8 +9,7 @@
¶ms;
--dry If given, doesn't do any real changes, but only shows - what would have been changed. +-
All other parameters will be regarded as part of the title of a single page, and the bot will only work on that single page. @@ -260,19 +259,13 @@ # This temporary array is used to read the page title if one single # page to work on is specified by the arguments. pageTitleParts = [] - # If dry is True, doesn't do any real changes, but only show - # what would have been changed. - dry = False
# Parse command line arguments for arg in pywikibot.handleArgs(): - if arg.startswith("-dry"): - dry = True - else: - # check if a standard argument like - # -start:XYZ or -ref:Asdf was given. - if not genFactory.handleArg(arg): - pageTitleParts.append(arg) + # check if a standard argument like + # -start:XYZ or -ref:Asdf was given. + if not genFactory.handleArg(arg): + pageTitleParts.append(arg)
if pageTitleParts != []: # We will only work on a single page. @@ -286,7 +279,7 @@ # The preloading generator is responsible for downloading multiple # pages from the wiki simultaneously. gen = pagegenerators.PreloadingGenerator(gen) - bot = BasicBot(gen, dry) + bot = BasicBot(gen, pywikibot.simulate) bot.run() else: pywikibot.showHelp()
Modified: trunk/pywikipedia/blockreview.py =================================================================== --- trunk/pywikipedia/blockreview.py 2012-06-13 09:10:13 UTC (rev 10353) +++ trunk/pywikipedia/blockreview.py 2012-06-13 10:26:56 UTC (rev 10354) @@ -9,8 +9,7 @@
The following parameters are supported:
--dry If given, doesn't do any real changes, but only shows - what would have been changed. +-
All other parameters will be regarded as part of the title of a single page, and the bot will only work on that single page. @@ -283,19 +282,14 @@ return False
def main(): - # If dry is True, doesn't do any real changes, but only show - # what would have been changed. - dry = show = False + show = False
# Parse command line arguments for arg in pywikibot.handleArgs(): - if arg == "-dry": - dry = True - else: - show = True + show = True
if not show: - bot = BlockreviewBot(dry) + bot = BlockreviewBot(pywikibot.simulate) bot.run() else: pywikibot.showHelp()
Modified: trunk/pywikipedia/djvutext.py =================================================================== --- trunk/pywikipedia/djvutext.py 2012-06-13 09:10:13 UTC (rev 10353) +++ trunk/pywikipedia/djvutext.py 2012-06-13 10:26:56 UTC (rev 10354) @@ -6,8 +6,6 @@
The following parameters are supported:
- -dry If given, doesn't do any real changes, but only shows - what would have been changed. -ask Ask for confirmation before uploading each page. (Default: ask when overwriting pages) -overwrite:no When asking for confirmation, the answer is no. @@ -40,7 +38,7 @@
class DjVuTextBot:
- def __init__(self, djvu, index, pages, ask=False, overwrite='ask', debug=False): + def __init__(self, djvu, index, pages, ask=False, overwrite='ask', dry=False): """ Constructor. Parameters: djvu : filename @@ -50,7 +48,7 @@ self.djvu = djvu self.index = index self.pages = pages - self.dry = debug + self.dry = dry self.ask = ask self.overwrite = overwrite
@@ -188,15 +186,12 @@ djvu = None pages = None # what would have been changed. - dry = False ask = False overwrite = 'ask'
# Parse command line arguments for arg in pywikibot.handleArgs(): - if arg.startswith("-dry"): - dry = True - elif arg.startswith("-ask"): + if arg.startswith("-ask"): ask = True elif arg.startswith("-overwrite:"): overwrite = arg[11:12] @@ -236,7 +231,7 @@ raise pywikibot.NoPage(u"Page '%s' does not exist" % index) pywikibot.output(u"uploading text from %s to %s" % (djvu, index_page.title(asLink=True)) ) - bot = DjVuTextBot(djvu, index, pages, ask, overwrite, dry) + bot = DjVuTextBot(djvu, index, pages, ask, overwrite, pywikibot.simulate) if not bot.has_text(): raise ValueError("No text layer in djvu file") bot.run()
Modified: trunk/pywikipedia/featured.py =================================================================== --- trunk/pywikipedia/featured.py 2012-06-13 09:10:13 UTC (rev 10353) +++ trunk/pywikipedia/featured.py 2012-06-13 10:26:56 UTC (rev 10354) @@ -35,8 +35,6 @@
-quiet no corresponding pages are displayed.
--dry for debug purposes. No changes will be made. - usage: featured.py [-interactive] [-nocache] [-top] [-after:zzzz] [-fromlang:xx,yy--zz|-fromall]
""" @@ -561,7 +559,6 @@ doAll = False part = False quiet = False - dry = False for arg in pywikibot.handleArgs(): if arg == '-interactive': interactive=1 @@ -586,8 +583,6 @@ processType = 'former' elif arg == '-quiet': quiet = True - elif arg == '-dry': - dry = True
if part: try: @@ -657,7 +652,8 @@ break elif fromsite != pywikibot.getSite(): featuredWithInterwiki(fromsite, pywikibot.getSite(), - template_on_top, processType, quiet, dry) + template_on_top, processType, quiet, + pywikibot.simulate) except KeyboardInterrupt: pywikibot.output('\nQuitting program...') finally:
Modified: trunk/pywikipedia/pagefromfile.py =================================================================== --- trunk/pywikipedia/pagefromfile.py 2012-06-13 09:10:13 UTC (rev 10353) +++ trunk/pywikipedia/pagefromfile.py 2012-06-13 10:26:56 UTC (rev 10354) @@ -33,8 +33,6 @@ -autosummary Use MediaWikis autosummary when creating a new page, overrides -summary in this case -minor set minor edit flag on page edits --dry Do not really upload pages, just check and report - messages
If the page to be uploaded already exists: -safe do nothing (default) @@ -146,14 +144,14 @@ }
def __init__(self, reader, force, append, summary, minor, autosummary, - debug,nocontents): + dry, nocontents): self.reader = reader self.force = force self.append = append self.summary = summary self.minor = minor self.autosummary = autosummary - self.dry = debug + self.dry = dry self.nocontents=nocontents
def run(self): @@ -318,7 +316,6 @@ summary = None minor = False autosummary = False - dry = False
for arg in pywikibot.handleArgs(): if arg.startswith("-start:"): @@ -335,8 +332,6 @@ append = "Bottom" elif arg == "-force": force=True - elif arg == "-dry": - dry = True elif arg == "-safe": force = False append = None @@ -358,8 +353,10 @@ pywikibot.output(u"Disregarding unknown argument %s." % arg)
reader = PageFromFileReader(filename, pageStartMarker, pageEndMarker, - titleStartMarker, titleEndMarker, include, notitle) - bot = PageFromFileRobot(reader, force, append, summary, minor, autosummary, dry,nocontents) + titleStartMarker, titleEndMarker, include, + notitle) + bot = PageFromFileRobot(reader, force, append, summary, minor, autosummary, + pywikibot.simulate, nocontents) bot.run()
if __name__ == "__main__":
Modified: trunk/pywikipedia/piper.py =================================================================== --- trunk/pywikipedia/piper.py 2012-06-13 09:10:13 UTC (rev 10353) +++ trunk/pywikipedia/piper.py 2012-06-13 10:26:56 UTC (rev 10354) @@ -20,9 +20,6 @@
¶ms;
- -dry If given, doesn't do any real changes, but only shows - what would have been changed. - -always Always commit changes without asking you to accept them
-filter: Filter the article text through this program, can be @@ -65,17 +62,17 @@ 'nl': u'Bot: paginatekst door %s geleid' }
- def __init__(self, generator, debug, filters, always): + def __init__(self, generator, dry, filters, always): """ Constructor. Parameters: * generator - The page generator that determines on which pages to work on. - * debug - If True, doesn't do any real changes, but only shows + * dry - If True, doesn't do any real changes, but only shows what would have been changed. * always - If True, don't prompt for changes """ self.generator = generator - self.dry = debug + self.dry = dry self.always = always self.filters = filters
@@ -173,9 +170,6 @@ # This temporary array is used to read the page title if one single # page to work on is specified by the arguments. pageTitleParts = [] - # If dry is True, doesn't do any real changes, but only show - # what would have been changed. - dry = False # will become True when the user uses the -always flag. always = False # The program to pipe stuff through @@ -183,9 +177,7 @@
# Parse command line arguments for arg in pywikibot.handleArgs(): - if arg.startswith("-dry"): - dry = True - elif arg.startswith("-filter:"): + if arg.startswith("-filter:"): prog = arg[8:] filters.append(prog) elif arg.startswith("-always"): @@ -208,7 +200,7 @@ # The preloading generator is responsible for downloading multiple # pages from the wiki simultaneously. gen = pagegenerators.PreloadingGenerator(gen) - bot = PiperBot(gen, dry, filters, always) + bot = PiperBot(gen, pywikibot.simulate, filters, always) bot.run() else: pywikibot.showHelp()
pywikipedia-svn@lists.wikimedia.org