jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/676729 )
Change subject: [bugfix] Fix bugs in imagetransfer.py ......................................................................
[bugfix] Fix bugs in imagetransfer.py
- Fix usage of -tofamily -tolang options in imagetransfer.py - fix bot.skip_run() - additional output of the transfer - print a more readable messages in UploadRobot - enable automatic_quit
Bug: T279232 Change-Id: Ic33049b1c44a4c1dc9d66f0a1666b8999685836f --- M pywikibot/specialbots/_upload.py M scripts/imagetransfer.py 2 files changed, 13 insertions(+), 10 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py index 149f13d..9c53532 100644 --- a/pywikibot/specialbots/_upload.py +++ b/pywikibot/specialbots/_upload.py @@ -4,7 +4,7 @@ Do not import classes directly from here but from specialbots. """ # -# (C) Pywikibot team, 2003-2020 +# (C) Pywikibot team, 2003-2021 # # Distributed under the terms of the MIT license. # @@ -224,8 +224,8 @@ filename = self.filename_prefix + filename if not self.keep_filename: pywikibot.output( - 'The filename on the target wiki will default to: %s' - % filename) + '\nThe filename on the target wiki will default to: {}\n' + .format(filename)) assert not self.opt.always newfn = pywikibot.input( 'Enter a better name, or press enter to accept:') @@ -271,9 +271,9 @@ continue
if not pywikibot.input_yn( - 'File format is not one of [%s], but %s. Continue?' - % (' '.join(allowed_formats), ext), - default=False, automatic_quit=False): + 'File format is not one of [{}], but {!r}. Continue?' + .format(' '.join(allowed_formats), ext), + default=False): continue
potential_file_page = pywikibot.FilePage(self.target_site, diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py index 43def4f..7581570 100755 --- a/scripts/imagetransfer.py +++ b/scripts/imagetransfer.py @@ -29,7 +29,7 @@ ¶ms; """ # -# (C) Pywikibot team, 2004-2020 +# (C) Pywikibot team, 2004-2021 # # Distributed under the terms of the MIT license. # @@ -167,6 +167,9 @@ @return: the filename which was used to upload the image """ sourceSite = sourceImagePage.site + pywikibot.output( + '\n>>> Transfer {source} from {source.site} to {target}\n' + .format(source=sourceImagePage, target=self.opt.target)) url = sourceImagePage.get_file_url() pywikibot.output('URL should be: ' + url) # localize the text that should be printed on image description page @@ -207,7 +210,7 @@ ignore_warning=self.opt.ignore_warning)
# try to upload - if bot.self.skip_run(): + if bot.skip_run(): return target_filename = bot.upload_file(url)
@@ -353,8 +356,8 @@ if target_code or target_family: site = pywikibot.Site() options.setdefault('target', - '{}:{}'.format(target_code or site.lang, - target_family or site.family)) + '{}:{}'.format(target_family or site.family, + target_code or site.lang))
bot = ImageTransferBot(generator=gen, **options) bot.run()