jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/634932 )
Change subject: [IMPR] reduce code complexity of HttpRequest.encoding()
......................................................................
[IMPR] reduce code complexity of HttpRequest.encoding()
Change-Id: I2cf45c9cde86469b363a5835bb09bbed6f8b50d5
---
M pywikibot/comms/threadedhttp.py
1 file changed, 26 insertions(+), 24 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/threadedhttp.py b/pywikibot/comms/threadedhttp.py
index 208dc8e..d6b98b3 100644
--- a/pywikibot/comms/threadedhttp.py
+++ b/pywikibot/comms/threadedhttp.py
@@ -134,34 +134,36 @@
@property
def encoding(self):
"""Detect the response encoding."""
- if not hasattr(self, '_encoding'):
- if self.charset is None and self.header_encoding is None:
- pywikibot.log("Http response doesn't contain a charset.")
- charset = 'latin1'
- else:
- charset = self.charset
+ if hasattr(self, '_encoding'):
+ return self._encoding
- if self.header_encoding is not None \
- and (charset is None
- or codecs.lookup(self.header_encoding)
- != codecs.lookup(charset)):
- if charset:
- pywikibot.warning(
- 'Encoding "{}" requested but "{}" received in the '
- 'header.'.format(charset, self.header_encoding))
+ if self.charset is None and self.header_encoding is None:
+ pywikibot.log("Http response doesn't contain a charset.")
+ charset = 'latin1'
+ else:
+ charset = self.charset
- # TODO: Buffer decoded content, weakref does remove it too
- # early (directly after this method)
- self._encoding = self._try_decode(self.header_encoding)
- else:
- self._encoding = None
+ _encoding = UnicodeError()
+ if self.header_encoding is not None \
+ and (charset is None
+ or codecs.lookup(self.header_encoding)
+ != codecs.lookup(charset)):
+ if charset:
+ pywikibot.warning(
+ 'Encoding "{}" requested but "{}" received in the '
+ 'header.'.format(charset, self.header_encoding))
- if charset and (isinstance(self._encoding, Exception)
- or self._encoding is None):
- self._encoding = self._try_decode(charset)
+ # TODO: Buffer decoded content, weakref does remove it too
+ # early (directly after this method)
+ _encoding = self._try_decode(self.header_encoding)
- if isinstance(self._encoding, Exception):
- raise self._encoding
+ if charset and isinstance(_encoding, Exception):
+ _encoding = self._try_decode(charset)
+
+ if isinstance(_encoding, Exception):
+ raise _encoding
+ else:
+ self._encoding = _encoding
return self._encoding
def _try_decode(self, encoding):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/634932
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2cf45c9cde86469b363a5835bb09bbed6f8b50d5
Gerrit-Change-Number: 634932
Gerrit-PatchSet: 3
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/635953 )
Change subject: [tests] Do not skip tests due to MaxlagTimeoutError
......................................................................
[tests] Do not skip tests due to MaxlagTimeoutError
After T242081 has been solved upstream, do not skip MaxlagTimeoutError
anymore to detect such failures again.
Bug: T242081
Change-Id: I7659adffa915e04adeea06937eca27e34ed4b43a
---
M pywikibot/data/api.py
1 file changed, 3 insertions(+), 8 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 00f7f38..b452ee4 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1988,19 +1988,14 @@
param_repr = str(self._params)
pywikibot.log('API Error: query=\n%s'
% pprint.pformat(param_repr))
- pywikibot.log(' response=\n%s'
- % result)
+ pywikibot.log(' response=\n{}'.format(result))
raise APIError(**result['error'])
except TypeError:
raise RuntimeError(result)
- msg = 'Maximum retries attempted due to maxlag without success.'
- if os.environ.get('PYWIKIBOT_TESTS_RUNNING', '0') == '1':
- import unittest
- raise unittest.SkipTest(msg)
-
- raise MaxlagTimeoutError(msg)
+ raise MaxlagTimeoutError(
+ 'Maximum retries attempted due to maxlag without success.')
def wait(self, delay=None):
"""Determine how long to wait after a failed request."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/635953
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I7659adffa915e04adeea06937eca27e34ed4b43a
Gerrit-Change-Number: 635953
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/635997 )
Change subject: [4.0] Remove Python 2 workarounds in family.py
......................................................................
[4.0] Remove Python 2 workarounds in family.py
Changes proposed by zhuyifei1999
Bug: T265817
Change-Id: Idfe7fd5262cd16da92253e0550b1c508bb1480a8
---
M pywikibot/family.py
1 file changed, 3 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index b25c9cb..aff0db5 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -45,21 +45,18 @@
# any Family class defined in this file are abstract
if cls in globals().values():
raise TypeError(
- 'Abstract Family class {0} cannot be instantiated; '
+ 'Abstract Family class {} cannot be instantiated; '
'subclass it instead'.format(cls.__name__))
# Override classproperty
cls.instance = super().__new__(cls)
- # staticmethod is because python 2.7 binds the lambda to the class
- cls.__new__ = staticmethod(lambda cls: cls.instance) # shortcut
+ cls.__new__ = lambda cls: cls.instance # shortcut
# don't use hasattr() here. consider only the class itself
if '__init__' in cls.__dict__:
# Initializer deprecated. Families should be immutable and any
# instance / class modification should go to allocator (__new__).
- # The function is read from __dict__ because deprecated expect a
- # function and python 2.7 binds the method to the class.
- cls.__init__ = deprecated(cls.__dict__['__init__'])
+ cls.__init__ = deprecated(cls.__init__)
# Invoke initializer immediately and make initializer no-op.
# This is to avoid repeated initializer invocation on repeated
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/635997
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Idfe7fd5262cd16da92253e0550b1c508bb1480a8
Gerrit-Change-Number: 635997
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/635900 )
Change subject: Update OpenStreetMap family
......................................................................
Update OpenStreetMap family
Publish additional wiki-specific settings I have set to operate a bot on
https://wiki.openstreetmap.org, the change appends the list of settings by
some names of templates, categories, and pages.
Change-Id: I69737a08e1bc932db32806a4f3a01aad6d91d7ea
---
M pywikibot/families/osm_family.py
1 file changed, 28 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/osm_family.py b/pywikibot/families/osm_family.py
index 107c595..7f25bb2 100644
--- a/pywikibot/families/osm_family.py
+++ b/pywikibot/families/osm_family.py
@@ -17,6 +17,34 @@
domain = 'wiki.openstreetmap.org'
code = 'en'
+ # Templates that indicate a category redirect
+ # Redirects to these templates are automatically included
+ category_redirect_templates = {
+ 'en': ('Category redirect',),
+ }
+
+ # A list of disambiguation template names in different languages
+ disambiguationTemplates = { # noqa: N815
+ 'en': ('Disambig',),
+ }
+
+ # A dict with the name of the category containing disambiguation
+ # pages for the various languages. Only one category per language,
+ # and without the namespace
+ disambcatname = {
+ 'en': 'Disambiguation',
+ }
+
+ # Subpages for documentation
+ doc_subpages = {
+ 'en': ('/doc',),
+ }
+
+ # Templates that indicate an edit should be avoided
+ edit_restricted_templates = {
+ 'en': ('In Bearbeitung',),
+ }
+
def protocol(self, code):
"""Return https as the protocol for this family."""
return 'https'
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/635900
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I69737a08e1bc932db32806a4f3a01aad6d91d7ea
Gerrit-Change-Number: 635900
Gerrit-PatchSet: 2
Gerrit-Owner: Tigerfell <tigerfell-688(a)tuta.io>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/635511 )
Change subject: [bugfix] convert expiry=True to expiry=0 in siteinfo.get()
......................................................................
[bugfix] convert expiry=True to expiry=0 in siteinfo.get()
For compatibility with other siteinfo functions and lower layers in
site and api functions handling expiry parameter.
Bug: T266084
Change-Id: I05adfd43c1a5d43e2a7135af0c760dd42708325e
---
M pywikibot/site/_siteinfo.py
1 file changed, 4 insertions(+), 0 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/_siteinfo.py b/pywikibot/site/_siteinfo.py
index 28f13cc..067acaf 100644
--- a/pywikibot/site/_siteinfo.py
+++ b/pywikibot/site/_siteinfo.py
@@ -275,6 +275,10 @@
get_default option is set to False.
@see: L{_get_siteinfo}
"""
+ # If expiry is True, convert it to 0 to be coherent with
+ # _get_siteinfo() and _get_general() docstring.
+ if expiry is True:
+ expiry = 0
# If expiry is a float or int convert to timedelta
# Note: bool is an instance of int
if isinstance(expiry, float) or type(expiry) == int:
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/635511
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I05adfd43c1a5d43e2a7135af0c760dd42708325e
Gerrit-Change-Number: 635511
Gerrit-PatchSet: 2
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged