jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/313793 )
Change subject: Replaced the word 'async' with 'asynchronous'
......................................................................
Replaced the word 'async' with 'asynchronous'
'async' is becoming proper keyword in Python 3.7. Hence, replaced it
with another word 'asynchronous' wherever 'async' was used as a
parameter.
Bug: T106230
Change-Id: I5f55b56f55932fb34db87b48bd1340082bd4ac49
---
M pywikibot/bot.py
M pywikibot/page.py
M scripts/cosmetic_changes.py
M scripts/interwiki.py
M scripts/replace.py
M tests/edit_tests.py
6 files changed, 41 insertions(+), 31 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index f99972e..1235b4c 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -99,7 +99,9 @@
debug, error, exception, log, output, stdout, warning,
)
from pywikibot.logging import critical
-from pywikibot.tools import deprecated, deprecated_args, PY2, PYTHON_VERSION
+from pywikibot.tools import (
+ deprecated, deprecate_arg, deprecated_args, PY2, PYTHON_VERSION,
+)
from pywikibot.tools._logging import (
LoggingFormatter as _LoggingFormatter,
RotatingFileHandler,
@@ -1254,6 +1256,7 @@
return True
+ @deprecate_arg('async', 'asynchronous') # T106230
@deprecated_args(comment='summary')
def userPut(self, page, oldtext, newtext, **kwargs):
"""
@@ -1268,7 +1271,7 @@
Keyword args used:
- * 'async' - passed to page.save
+ * 'asynchronous' - passed to page.save
* 'summary' - passed to page.save
* 'show_diff' - show changes between oldtext and newtext (enabled)
* 'ignore_save_related_errors' - report and ignore (disabled)
@@ -1315,8 +1318,8 @@
if not self.user_confirm('Do you want to accept these changes?'):
return
- if 'async' not in kwargs and self.getOption('always'):
- kwargs['async'] = True
+ if 'asynchronous' not in kwargs and self.getOption('always'):
+ kwargs['asynchronous'] = True
ignore_save_related_errors = kwargs.pop('ignore_save_related_errors',
False)
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 1885aef..9554068 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1154,9 +1154,10 @@
# no restricting template found
return True
+ @deprecate_arg('async', 'asynchronous') # T106230
@deprecated_args(comment='summary', sysop=None)
def save(self, summary=None, watch=None, minor=True, botflag=None,
- force=False, async=False, callback=None,
+ force=False, asynchronous=False, callback=None,
apply_cosmetic_changes=None, quiet=False, **kwargs):
"""
Save the current contents of page's text to the wiki.
@@ -1182,7 +1183,7 @@
True if user has bot status, False if not)
@param force: if True, ignore botMayEdit() setting
@type force: bool
- @param async: if True, launch a separate thread to save
+ @param asynchronous: if True, launch a separate thread to save
asynchronously
@param callback: a callable object that will be called after the
page put operation. This object must take two arguments: (1) a
@@ -1195,8 +1196,8 @@
@type apply_cosmetic_changes: bool or None
@param quiet: enable/disable successful save operation message;
defaults to False.
- In async mode, if True, it is up to the calling bot to manage the
- ouput e.g. via callback.
+ In asynchronous mode, if True, it is up to the calling bot to
+ manage the ouput e.g. via callback.
@type quiet: bool
"""
if not summary:
@@ -1208,19 +1209,22 @@
if not force and not self.botMayEdit():
raise pywikibot.OtherPageSaveError(
self, "Editing restricted by {{bots}} template")
- if async:
+ if asynchronous:
pywikibot.async_request(self._save, summary=summary, watch=watch,
minor=minor, botflag=botflag,
- async=async, callback=callback,
+ asynchronous=asynchronous,
+ callback=callback,
cc=apply_cosmetic_changes,
quiet=quiet, **kwargs)
else:
self._save(summary=summary, watch=watch, minor=minor,
- botflag=botflag, async=async, callback=callback,
- cc=apply_cosmetic_changes, quiet=quiet, **kwargs)
+ botflag=botflag, asynchronous=asynchronous,
+ callback=callback, cc=apply_cosmetic_changes,
+ quiet=quiet, **kwargs)
def _save(self, summary=None, watch=None, minor=True, botflag=None,
- async=False, callback=None, cc=None, quiet=False, **kwargs):
+ asynchronous=False, callback=None, cc=None, quiet=False,
+ **kwargs):
"""Helper function for save()."""
err = None
link = self.title(asLink=True)
@@ -1240,7 +1244,7 @@
err = edit_err # edit_err will be deleted in the end of the scope
pywikibot.log(u"Error saving page %s (%s)\n" % (link, err),
exc_info=True)
- if not callback and not async:
+ if not callback and not asynchronous:
if isinstance(err, pywikibot.PageSaveRelatedError):
raise err
raise pywikibot.OtherPageSaveError(self, err)
@@ -1283,9 +1287,10 @@
comment += i18n.twtranslate(self.site, 'cosmetic_changes-append')
return comment
+ @deprecate_arg('async', 'asynchronous') # T106230
@deprecated_args(comment='summary')
def put(self, newtext, summary=u'', watchArticle=None, minorEdit=True,
- botflag=None, force=False, async=False, callback=None, **kwargs):
+ botflag=None, force=False, asynchronous=False, callback=None, **kwargs):
"""
Save the page with the contents of the first argument as the text.
@@ -1299,8 +1304,8 @@
"""
self.text = newtext
self.save(summary=summary, watch=watchArticle, minor=minorEdit,
- botflag=botflag, force=force, async=async, callback=callback,
- **kwargs)
+ botflag=botflag, force=force, asynchronous=asynchronous,
+ callback=callback, **kwargs)
@deprecated_args(comment='summary')
def put_async(self, newtext, summary=u'', watchArticle=None,
@@ -1315,8 +1320,8 @@
backwards-compatibility.
"""
self.put(newtext, summary=summary, watchArticle=watchArticle,
- minorEdit=minorEdit, botflag=botflag, force=force, async=True,
- callback=callback, **kwargs)
+ minorEdit=minorEdit, botflag=botflag, force=force,
+ asynchronous=True, callback=callback, **kwargs)
def watch(self, unwatch=False):
"""
@@ -1354,7 +1359,7 @@
See save() method docs for all parameters.
The following parameters will be overridden by this method:
- - summary, watch, minor, force, async
+ - summary, watch, minor, force, asynchronous
Parameter botflag is False by default.
@@ -1365,9 +1370,9 @@
# ensure always get the page text and not to change it.
del self.text
self.save(summary='Pywikibot touch edit', watch='nochange',
- minor=False, botflag=botflag, force=True, async=False,
- callback=callback, apply_cosmetic_changes=False,
- **kwargs)
+ minor=False, botflag=botflag, force=True,
+ asynchronous=False, callback=callback,
+ apply_cosmetic_changes=False, **kwargs)
else:
raise pywikibot.NoPage(self)
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 1fc260f..9117d5a 100644
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -77,7 +77,7 @@
if changedText is not False:
self.put_current(new_text=changedText,
summary=self.getOption('summary'),
- async=self.getOption('async'))
+ asynchronous=self.getOption('async'))
def main(*args):
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 0f45e60..7b4f5bc 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -504,7 +504,7 @@
minlinks = 0
quiet = False
restoreAll = False
- async = False
+ asynchronous = False
summary = u''
repository = False
@@ -613,7 +613,7 @@
elif arg == '-quiet':
self.quiet = True
elif arg == '-async':
- self.async = True
+ self.asynchronous = True
elif arg.startswith('-summary'):
if len(arg) == 8:
self.summary = pywikibot.input(
@@ -1956,7 +1956,8 @@
page.text = newtext
while True:
try:
- page.save(summary=mcomment, async=self.conf.async,
+ page.save(summary=mcomment,
+ asynchronous=self.conf.asynchronous,
nocreate=True)
except pywikibot.NoCreateError:
pywikibot.exception()
diff --git a/scripts/replace.py b/scripts/replace.py
index 1abd206..f235c95 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -128,7 +128,7 @@
"""
#
# (C) Daniel Herding, 2004-2012
-# (C) Pywikibot team, 2004-2016
+# (C) Pywikibot team, 2004-2017
#
# Distributed under the terms of the MIT license.
#
@@ -790,7 +790,8 @@
self.options['always'] = True
if choice == 'y':
page.text = new_text
- page.save(summary=self.generate_summary(applied), async=True,
+ page.save(summary=self.generate_summary(applied),
+ asynchronous=True,
callback=self._replace_async_callback, quiet=True)
while not self._pending_processed_titles.empty():
proc_title, res = self._pending_processed_titles.get()
diff --git a/tests/edit_tests.py b/tests/edit_tests.py
index bd12c77..31f6c83 100644
--- a/tests/edit_tests.py
+++ b/tests/edit_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Tests for editing pages."""
#
-# (C) Pywikibot team, 2015
+# (C) Pywikibot team, 2015-2017
#
# Distributed under the terms of the MIT license.
#
@@ -55,7 +55,7 @@
ts = str(time.time())
p = pywikibot.Page(self.site, 'User:John Vandenberg/async test write')
p.text = ts
- p.save(async=True, callback=callback)
+ p.save(asynchronous=True, callback=callback)
page_put_queue.join()
--
To view, visit
https://gerrit.wikimedia.org/r/313793
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5f55b56f55932fb34db87b48bd1340082bd4ac49
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ayushjain19 <ayushjain081(a)gmail.com>
Gerrit-Reviewer: AbdealiJK <abdealikothari(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zppix <Megadev44s.mail(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>