jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/607317 )
Change subject: [doc] Update ROADMAP.rst
......................................................................
[doc] Update ROADMAP.rst
Change-Id: I120ebe3174f3ade40c72083298073748a3c88ee0
---
M ROADMAP.rst
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
Dvorapa: Looks good to me, but someone else must approve
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 96b0743..b47d6c2 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -3,6 +3,8 @@
**Note: This is the last release supporting Python 2 and Python 3.4**
+* Wait in BaseBot.exit() until asynchronous saving pages are completed
+* Solve IndexError when showing an empty diff with a non-zero context (T252724)
* linktrails were added or updated for a lot of sites
* Resolve namespaces with underlines (T252940)
* Fix getversion_svn for Python 3.6+ (T253617, T132292)
@@ -12,6 +14,7 @@
Future releases
~~~~~~~~~~~~~~~
+* (current) tools.count, tools.Counter, tools.OrderedDict and ContextManagerWrapper will be removed
* (current) getFilesFromAnHash and getImagesFromAnHash Site methods will be removed
* 3.0.20200508: PageNotFound, SpamfilterError and UserActionRefuse exceptions will be removed (T253681)
* 3.0.20200508: Page.getVersionHistory and Page.fullVersionHistory() methods will be removed (T136513, T151110)
--
To view, visit https://gerrit.wikimedia.org/r/607317
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I120ebe3174f3ade40c72083298073748a3c88ee0
Gerrit-Change-Number: 607317
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/606660 )
Change subject: [cleanup] show a FutureWarning for decode parameter in Page.title()
......................................................................
[cleanup] show a FutureWarning for decode parameter in Page.title()
decode parameter was not ported from core. Show a FutureWarning that
this parameter an be removed shortly after 12 years of non functional
Change-Id: Icf6ed63e1698de0b9c837584c0eb009f427c6ef1
---
M pywikibot/page/__init__.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 9085f15..6b3f3a5 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -295,7 +295,7 @@
return self._pageid
@deprecated_args(
- decode=None, savetitle='as_url', withNamespace='with_ns',
+ decode=True, savetitle='as_url', withNamespace='with_ns',
withSection='with_section', forceInterwiki='force_interwiki',
asUrl='as_url', asLink='as_link', allowInterwiki='allow_interwiki')
def title(self, underscore=False, with_ns=True,
--
To view, visit https://gerrit.wikimedia.org/r/606660
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Icf6ed63e1698de0b9c837584c0eb009f427c6ef1
Gerrit-Change-Number: 606660
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/606654 )
Change subject: [IMPR] Improvements for deprecated_args decorator
......................................................................
[IMPR] Improvements for deprecated_args decorator
- extended documentation for deprecate_arg and deprecated_args
- decrease nested flow statements
- enable FutureWarning if the value is True
- do not print any warning if the value is an empty string,
originally intended for True but never worked
Change-Id: I276d91d9ad9f995d7b983580f27f3cab6ba257d0
---
M pywikibot/tools/__init__.py
1 file changed, 66 insertions(+), 31 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index a6e7c88..02b41f0 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -1734,17 +1734,45 @@
def deprecate_arg(old_arg, new_arg):
- """Decorator to declare old_arg deprecated and replace it with new_arg."""
+ """Decorator to declare old_arg deprecated and replace it with new_arg.
+
+ Usage:
+
+ @deprecate_arg('foo', 'bar')
+ def my_function(bar='baz'): pass
+ # replaces 'foo' keyword by 'bar' used by my_function
+
+ @deprecare_arg('foo', None)
+ def my_function(): pass
+ # ignores 'foo' keyword no longer used by my_function
+
+ deprecated_args decorator should be used in favour of this
+ deprecate_arg decorator but it is held to deprecate args which become
+ a reserved word in future Python releases and to prevent syntax errors.
+
+ @param old_arg: old keyword
+ @type old_arg: str
+ @param new_arg: new keyword
+ @type new_arg: str or None or bool
+ """
return deprecated_args(**{old_arg: new_arg})
def deprecated_args(**arg_pairs):
- """
- Decorator to declare multiple args deprecated.
+ """Decorator to declare multiple args deprecated.
- @param arg_pairs: Each entry points to the new argument name. With True or
- None it drops the value and prints a warning. If False it just drops
- the value.
+ Usage:
+
+ @deprecated_args(foo='bar', baz=None)
+ def my_function(bar='baz'): pass
+ # replaces 'foo' keyword by 'bar' and ignores 'baz' keyword
+
+ @param arg_pairs: Each entry points to the new argument name. If an
+ argument is to be removed, the value may be one of the following:
+ - None: shows a DeprecationWarning
+ - False: shows a PendingDeprecationWarning
+ - True: shows a FutureWarning (only once)
+ - empty string: no warning is printed
"""
def decorator(obj):
"""Outer wrapper.
@@ -1770,30 +1798,37 @@
'old_arg': old_arg,
'new_arg': new_arg,
}
- if old_arg in __kw:
- if new_arg not in [True, False, None]:
- if new_arg in __kw:
- warn('%(new_arg)s argument of %(name)s '
- 'replaces %(old_arg)s; cannot use both.'
- % output_args,
- RuntimeWarning, depth)
- else:
- # If the value is positionally given this will
- # cause a TypeError, which is intentional
- warn('%(old_arg)s argument of %(name)s '
- 'is deprecated; use %(new_arg)s instead.'
- % output_args,
- DeprecationWarning, depth)
- __kw[new_arg] = __kw[old_arg]
+ if old_arg not in __kw:
+ continue
+
+ if new_arg not in [True, False, None, '']:
+ if new_arg in __kw:
+ warn('{new_arg} argument of {name} '
+ 'replaces {old_arg}; cannot use both.'
+ .format(**output_args),
+ RuntimeWarning, depth)
else:
- if new_arg is False:
- cls = PendingDeprecationWarning
- else:
- cls = DeprecationWarning
- warn('%(old_arg)s argument of %(name)s is deprecated.'
- % output_args,
- cls, depth)
- del __kw[old_arg]
+ # If the value is positionally given this will
+ # cause a TypeError, which is intentional
+ warn('{old_arg} argument of {name} '
+ 'is deprecated; use {new_arg} instead.'
+ .format(**output_args),
+ DeprecationWarning, depth)
+ __kw[new_arg] = __kw[old_arg]
+ elif new_arg == '':
+ pass
+ else:
+ if new_arg is False:
+ cls = PendingDeprecationWarning
+ elif new_arg is True:
+ cls = FutureWarning
+ else: # new_arg is None
+ cls = DeprecationWarning
+ warn('{old_arg} argument of {name} is deprecated.'
+ .format(**output_args),
+ cls, depth)
+ del __kw[old_arg]
+
return obj(*__args, **__kw)
if not __debug__:
@@ -1810,8 +1845,8 @@
for old_arg, new_arg in arg_pairs.items():
params[old_arg] = inspect.Parameter(
old_arg, kind=inspect._POSITIONAL_OR_KEYWORD,
- default='[deprecated name of ' + new_arg + ']'
- if new_arg not in [True, False, None]
+ default='[deprecated name of {}]'.format(new_arg)
+ if new_arg not in [True, False, None, '']
else NotImplemented)
params = collections.OrderedDict(sorted(params.items(),
key=lambda x: x[1].kind))
--
To view, visit https://gerrit.wikimedia.org/r/606654
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I276d91d9ad9f995d7b983580f27f3cab6ba257d0
Gerrit-Change-Number: 606654
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/607753 )
Change subject: [cleanup] print a FutureWarning for deprecated tools
......................................................................
[cleanup] print a FutureWarning for deprecated tools
- print a FutureWarning for tools.Counter, tools.OrderedDict which should
be replaced by the corresponding collections classes
- print a FutureWarning for tools.count which should be replaced by
itertools.count
- print a FutureWarning for ContextManagerWrapper which should be replaced
by other contextlib classes and functions
All of them where introduced for Python 2.6 and releases prior than 2.7.2
which where dropped more than 4 years ago. This stuff should be removed
soon.
Change-Id: Ibb80f6a5a7c2ca01cb765ff8075b7d02ec18553a
---
M pywikibot/tools/__init__.py
1 file changed, 6 insertions(+), 4 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index a6e7c88..edaf755 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -2198,9 +2198,11 @@
wrapper = ModuleDeprecationWrapper(__name__)
-wrapper._add_deprecated_attr('Counter', collections.Counter, since='20160111')
+wrapper._add_deprecated_attr('Counter', collections.Counter, since='20160111',
+ future_warning=True)
wrapper._add_deprecated_attr('OrderedDict', collections.OrderedDict,
- since='20160111')
-wrapper._add_deprecated_attr('count', itertools.count, since='20160111')
+ since='20160111', future_warning=True)
+wrapper._add_deprecated_attr('count', itertools.count, since='20160111',
+ future_warning=True)
wrapper._add_deprecated_attr('ContextManagerWrapper', replacement_name='',
- since='20180402')
+ since='20180402', future_warning=True)
--
To view, visit https://gerrit.wikimedia.org/r/607753
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibb80f6a5a7c2ca01cb765ff8075b7d02ec18553a
Gerrit-Change-Number: 607753
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/589900 )
Change subject: [IMPR] derive ReplaceRobot from ExistingPageBot
......................................................................
[IMPR] derive ReplaceRobot from ExistingPageBot
- use ExistingPageBot to skip NoPage exception
- move isTitleExcepted and has_permission() checking
to skip_page method
- directly leave treat method if isTextExcepted or
new_text == original_text after replacements
Change-Id: Idbc1d9764b25ce7376f1199a12e57087fbd5a5eb
---
M scripts/replace.py
1 file changed, 24 insertions(+), 24 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, but someone else must approve
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py
index e957427..6c50f31 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -156,7 +156,7 @@
# Imports predefined replacements tasks from fixes.py
from pywikibot import fixes
from pywikibot import i18n, textlib, pagegenerators
-from pywikibot.bot import SingleSiteBot
+from pywikibot.bot import ExistingPageBot, SingleSiteBot
from pywikibot.tools import (
chars,
deprecated,
@@ -498,7 +498,7 @@
return False
-class ReplaceRobot(SingleSiteBot):
+class ReplaceRobot(SingleSiteBot, ExistingPageBot):
"""A bot that can do text replacements.
@@ -713,46 +713,46 @@
semicolon = self.site.mediawiki_message('semicolon-separator')
return semicolon.join(summary_messages)
+ def skip_page(self, page):
+ """Check whether treat should be skipped for the page."""
+ if self.isTitleExcepted(page.title()):
+ pywikibot.warning(
+ 'Skipping {} because the title is on the exceptions list.'
+ .format(page))
+ return True
+
+ if not page.has_permission():
+ pywikibot.warning("You can't edit page {}".format(page))
+ return True
+
+ return super(ReplaceRobot, self).skip_page(page)
+
def treat(self, page):
"""Work on each page retrieved from generator."""
- if self.isTitleExcepted(page.title()):
- pywikibot.output(
- 'Skipping {0} because the title is on the exceptions list.'
- .format(page.title(as_link=True)))
- return
-
- try:
- # Load the page's text from the wiki
- original_text = page.get(get_redirect=True)
- if not page.has_permission():
- pywikibot.output("You can't edit page "
- + page.title(as_link=True))
- return
- except pywikibot.NoPage:
- pywikibot.output('Page {0} not found'
- .format(page.title(as_link=True)))
- return
-
+ original_text = page.text
applied = set()
new_text = original_text
last_text = None
context = 0
while True:
if self.isTextExcepted(new_text):
- pywikibot.output('Skipping {0} because it contains text '
+ pywikibot.output('Skipping {} because it contains text '
'that is on the exceptions list.'
- .format(page.title(as_link=True)))
- break
+ .format(page))
+ return
+
while new_text != last_text:
last_text = new_text
new_text = self.apply_replacements(last_text, applied,
page)
if not self.getOption('recursive'):
break
+
if new_text == original_text:
pywikibot.output('No changes were necessary in '
+ page.title(as_link=True))
- break
+ return
+
if self.addcat:
# Fetch only categories in wikitext, otherwise the others
# will be explicitly added.
--
To view, visit https://gerrit.wikimedia.org/r/589900
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Idbc1d9764b25ce7376f1199a12e57087fbd5a5eb
Gerrit-Change-Number: 589900
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/607253 )
Change subject: [doc] Update ROADMAP.rst
......................................................................
[doc] Update ROADMAP.rst
Change-Id: I81ef7e69133e9b5000ff5e38fd8e733d9ef1c319
---
M ROADMAP.rst
1 file changed, 2 insertions(+), 0 deletions(-)
Approvals:
Dvorapa: Looks good to me, but someone else must approve
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index e8373ee..96b0743 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -3,6 +3,7 @@
**Note: This is the last release supporting Python 2 and Python 3.4**
+* linktrails were added or updated for a lot of sites
* Resolve namespaces with underlines (T252940)
* Fix getversion_svn for Python 3.6+ (T253617, T132292)
* Bugfixes and improvements
@@ -11,6 +12,7 @@
Future releases
~~~~~~~~~~~~~~~
+* (current) getFilesFromAnHash and getImagesFromAnHash Site methods will be removed
* 3.0.20200508: PageNotFound, SpamfilterError and UserActionRefuse exceptions will be removed (T253681)
* 3.0.20200508: Page.getVersionHistory and Page.fullVersionHistory() methods will be removed (T136513, T151110)
* 3.0.20200405: Site and Page methods deprecated for 10 years or longer will be removed
--
To view, visit https://gerrit.wikimedia.org/r/607253
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I81ef7e69133e9b5000ff5e38fd8e733d9ef1c319
Gerrit-Change-Number: 607253
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)