Gallaecio has uploaded a new change for review. https://gerrit.wikimedia.org/r/127454
Change subject: Fix replace.py ignoring the -lang parameter ...................................................................... Fix replace.py ignoring the -lang parameter Since the generator is initialized before the -lang parameter reaches the global pywikibot parameter handling, it sometimes may happen that you ask replace.py for a specific language of a site using the -lang parameter, and replace.py would ignore this and search on the default (e.g. English) version of the site. This is now fixed by initializing the generator only after pywikibot has handled all global parameters. Change-Id: I61c2987505eff17bf53994b084283ac3ca601aa4 --- M scripts/replace.py 1 file changed, 17 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/54/127454/1 diff --git a/scripts/replace.py b/scripts/replace.py index ad9c11b..16a427d 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -441,6 +441,7 @@ # summary message summary_commandline = False edit_summary = u"" + unhandledArgs = [] # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] @@ -478,18 +479,13 @@ allowoverlap = False # Do not recurse replacement recursive = 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. - genFactory = pagegenerators.GeneratorFactory() # Between a regex and another (using -fix) sleep some time (not to waste # too much CPU sleep = None # Read commandline parameters. + unhandledArgs = [] for arg in pywikibot.handleArgs(*args): - if genFactory.handleArg(arg): - continue if arg == '-regex': regex = True elif arg.startswith('-xmlstart'): @@ -543,8 +539,23 @@ elif arg.startswith('-allowoverlap'): allowoverlap = True else: + unhandledArgs.append(arg) + + # 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. + # Note: You must create the generator factory after you parse other + # parameters, so that the generator factory uses the right site if specified + # with the ‘-family’ and ‘-lang’ command-line parameters. + genFactory = pagegenerators.GeneratorFactory() + for arg in unhandledArgs: + if genFactory.handleArg(arg): + continue + else: commandline_replacements.append(arg) + pywikibot.Site().login() + genFactory.site = pywikibot.Site() gen = genFactory.getCombinedGenerator() if (len(commandline_replacements) % 2): raise pywikibot.Error('require even number of replacements.') -- To view, visit https://gerrit.wikimedia.org/r/127454 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I61c2987505eff17bf53994b084283ac3ca601aa4 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: Gallaecio <adriyeticha...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits