jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/494677 )
Change subject: [IMPR] use site.watch() when calling site.watchpage()
......................................................................
[IMPR] use site.watch() when calling site.watchpage()
- use site.watch() when calling site.watchpage() and remove code
duplication.
- self.watchpage is old enough to ommit the detailed api response.
site.watch should be used in that case which raises a KeyError
in such case.
Change-Id: I1143f0a8fa5c409760a656f154f28b79ad2ece94
---
M pywikibot/site.py
1 file changed, 7 insertions(+), 10 deletions(-)
Approvals:
Huji: Looks good to me, approved
D3r1ck01: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ffa45da..36ba13c 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -6082,6 +6082,7 @@
if False add them (default).
@return: True if API returned expected response; False otherwise
@rtype: bool
+ @raises KeyError: 'watch' isn't in API response
"""
parameters = {'action': 'watch',
@@ -6125,16 +6126,12 @@
@rtype: bool
"""
- parameters = {'action': 'watch',
- 'title': page,
- 'token': self.tokens['watch'],
- 'unwatch': unwatch}
- req = self._simple_request(**parameters)
- result = req.submit()
- if 'watch' not in result:
- pywikibot.error('watchpage: Unexpected API response:\n%s' % result)
- return False
- return ('unwatched' if unwatch else 'watched') in result['watch']
+ try:
+ result = self.watch(page, unwatch)
+ except KeyError:
+ pywikibot.error('watchpage: Unexpected API response')
+ result = False
+ return result
@must_be(group='user')
def purgepages(
--
To view, visit https://gerrit.wikimedia.org/r/494677
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: I1143f0a8fa5c409760a656f154f28b79ad2ece94
Gerrit-Change-Number: 494677
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/569286 )
Change subject: [IMPR] Issue DeprecationWarning for sysop in Site()
......................................................................
[IMPR] Issue DeprecationWarning for sysop in Site()
Issue DeprecationWarning for sysop in Site()
Change-Id: I79fcfb475ea67ff9913d63a20536c3e5bc087b86
---
M pywikibot/__init__.py
M tests/utils.py
2 files changed, 6 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index cbb6ff3..c8a66dc 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -62,6 +62,7 @@
classproperty,
deprecated as __deprecated,
deprecate_arg as _deprecate_arg,
+ issue_deprecation_warning,
normalize_username,
MediaWikiVersion as _MediaWikiVersion,
redirect_func,
@@ -1222,6 +1223,10 @@
"""
_logger = 'wiki'
+ if sysop is not None:
+ issue_deprecation_warning('positional argument of "sysop"', depth=3,
+ warning_class=DeprecationWarning,
+ since='20190907')
if url:
# Either code and fam or only url
if code or fam:
diff --git a/tests/utils.py b/tests/utils.py
index 56e5f09..f9118da 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -601,7 +601,7 @@
@type command: list of unicode
"""
if PY2 or PYTHON_VERSION < (3, 5, 0):
- command.insert(1, '-W ignore::FutureWarning:pywikibot:127')
+ command.insert(1, '-W ignore::FutureWarning:pywikibot:128')
if cryptography_version and cryptography_version < [1, 3, 4]:
command.insert(1, '-W ignore:Old version of cryptography:Warning')
# Any environment variables added on Windows must be of type
--
To view, visit https://gerrit.wikimedia.org/r/569286
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: I79fcfb475ea67ff9913d63a20536c3e5bc087b86
Gerrit-Change-Number: 569286
Gerrit-PatchSet: 6
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(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/571103 )
Change subject: [bugfix] Fix some typos in docs
......................................................................
[bugfix] Fix some typos in docs
Change-Id: I2ae165208e2b0818b0abc881988220f8bd887efd
---
M pywikibot/site.py
M scripts/replace.py
2 files changed, 2 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ffa45da..6a8299e 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -8437,7 +8437,7 @@
@type language: str
@param total: Maximum number of pages to retrieve in total, or None in
case of no limit.
- @type limit: int or None
+ @type total: int or None
@return: 'search' list from API output.
@rtype: api.APIGenerator
"""
diff --git a/scripts/replace.py b/scripts/replace.py
index 1c30090..791250d 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -532,7 +532,7 @@
@param allowoverlap: when matches overlap, all of them are replaced.
@type allowoverlap: bool
@param recursive: Recurse replacement as long as possible.
- @type recursice: bool
+ @type recursive: bool
@warning: Be careful, this might lead to an infinite loop.
@param addedCat: category to be added to every page touched
@type addedCat: pywikibot.Category or str or None
--
To view, visit https://gerrit.wikimedia.org/r/571103
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: I2ae165208e2b0818b0abc881988220f8bd887efd
Gerrit-Change-Number: 571103
Gerrit-PatchSet: 8
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: Mpaa <mpaa.wiki(a)gmail.com>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/512535 )
Change subject: [IMPR] make date.FormatDate class a function (PEP20)
......................................................................
[IMPR] make date.FormatDate class a function (PEP20)
- deprecate date.FormatDate class which is a function encapsulated in a class
- format_date function is to be used instead
- reuse dayMnthFmts instead of concatening again
- introduce full range checking for month and day value
- replace FormatDate with format_date in pagegenerators.py
Change-Id: I36900f2931398c4adb967acec010903e27b01e71
---
M pywikibot/date.py
M pywikibot/pagegenerators.py
2 files changed, 37 insertions(+), 5 deletions(-)
Approvals:
Dvorapa: Looks good to me, but someone else must approve
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/date.py b/pywikibot/date.py
index 49a22ea..1cd5c5e 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -19,6 +19,7 @@
import re
from string import digits as _decimalDigits # noqa: N812
+from pywikibot import Site
from pywikibot.textlib import NON_LATIN_DIGITS
from pywikibot.tools import first_lower, first_upper, deprecated, UnicodeType
@@ -2215,9 +2216,10 @@
return None, None
+@deprecated('date.format_date', since='20190526')
class FormatDate(object):
- """Format a date."""
+ """DEPRECATED. Format a date."""
def __init__(self, site):
"""Initializer."""
@@ -2225,7 +2227,36 @@
def __call__(self, m, d):
"""Return a formatted month and day."""
- return formats[dayMnthFmts[m - 1]][self.site.lang](d)
+ return format_date(m, d, self.site)
+
+
+def format_date(month, day, lang=None, year=2000):
+ """Format a date localized to given lang.
+
+ @param month: month in range of 1..12
+ @type month: int
+ @param day: day of month in range of 1..31
+ @type day: int
+ @param lang: a site object or language key. Defaults to current site.
+ @type lang: BaseSite or string
+ @param year: year for which the date is to be formatted. always 29 will be
+ given For February except the year is given. Default is leap year 2000.
+ @type year: int
+ @return: localized date like "January 11"
+ @rtype: str
+ @raises ValueError: Wrong day value; must be 1-28/29/30/31
+ @raises IllegalMonthError: bad month number; must be 1-12
+ """
+ if not lang:
+ lang = Site().lang
+ elif hasattr(lang, 'lang'):
+ lang = lang.lang
+ max_day = calendar.monthrange(year, month)[1]
+ if not 1 <= day <= max_day:
+ raise ValueError(
+ 'Wrong day value {day}; must be 1-{max_day}'
+ .format(day=day, max_day=max_day))
+ return formats[dayMnthFmts[month - 1]][lang](day)
def formatYear(lang, year):
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 325d905..011dfd9 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -2904,12 +2904,13 @@
"""
if site is None:
site = pywikibot.Site()
- fd = date.FormatDate(site)
- firstPage = pywikibot.Page(site, fd(start_month, 1))
+ lang = site.lang
+ firstPage = pywikibot.Page(site, date.format_date(start_month, 1, lang))
pywikibot.output('Starting with %s' % firstPage.title(as_link=True))
for month in range(start_month, end_month + 1):
for day in range(1, calendar.monthrange(year, month)[1] + 1):
- yield pywikibot.Page(pywikibot.Link(fd(month, day), site))
+ yield pywikibot.Page(
+ pywikibot.Link(date.format_date(month, day, lang), site))
def WikidataPageFromItemGenerator(gen, site):
--
To view, visit https://gerrit.wikimedia.org/r/512535
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: I36900f2931398c4adb967acec010903e27b01e71
Gerrit-Change-Number: 512535
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/571074 )
Change subject: [cleanup] Throw FutureWarning with backports.py functions
......................................................................
[cleanup] Throw FutureWarning with backports.py functions
Bug: T244664
Change-Id: I59cb34bd43a0845751e3e8c6c47b17e813d2bd5e
---
M HISTORY.rst
M pywikibot/backports.py
2 files changed, 6 insertions(+), 4 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index c9f0dfc..05fdd57 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,7 @@
Current release
---------------
+* backports.py will be removed with next release (T244664)
* stdnum package is required for ISBN scripts and cosmetic_changes (T132919, T144288, T241141)
* preload urllib.quote() with Python 2 (T243710, T222623)
* Drop isbn_hyphenate package due to outdated data (T243157)
diff --git a/pywikibot/backports.py b/pywikibot/backports.py
index a190eba..59bc5f5 100644
--- a/pywikibot/backports.py
+++ b/pywikibot/backports.py
@@ -5,7 +5,7 @@
Their usage is deprecated and this module could be dropped soon.
"""
#
-# (C) Pywikibot team, 2014-2018
+# (C) Pywikibot team, 2014-2020
#
# Distributed under the terms of the MIT license.
#
@@ -18,7 +18,8 @@
from pywikibot.tools import deprecated
-@deprecated('difflib._format_range_unified', since='20160111')
+@deprecated('difflib._format_range_unified', since='20160111',
+ future_warning=True)
def format_range_unified(start, stop):
"""
Convert range to the "ed" format.
@@ -29,7 +30,7 @@
return _format_range_unified(start, stop)
-@deprecated('logging.NullHandler', since='20160111')
+@deprecated('logging.NullHandler', since='20160111', future_warning=True)
class NullHandler(logging.NullHandler):
"""This handler does nothing."""
@@ -37,7 +38,7 @@
pass
-@deprecated('logging.captureWarnings', since='20160111')
+@deprecated('logging.captureWarnings', since='20160111', future_warning=True)
def captureWarnings(capture):
"""
Capture warnings into logging.
--
To view, visit https://gerrit.wikimedia.org/r/571074
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: I59cb34bd43a0845751e3e8c6c47b17e813d2bd5e
Gerrit-Change-Number: 571074
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)