jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/600941 )
Change subject: [IMPR] Show global options with pwb.py
......................................................................
[IMPR] Show global options with pwb.py
Enable global options handling even if no filename is given for
pwb.py. This makes it possible that pwb.py -help prints global
options which are handled py pwb.py wrapper script and provides
global options even if a script does not call
pywikibot.handle_args()
Change-Id: I9524c1f1a95a0db21e94a5875831ef4f4f039b3d
---
M pwb.py
1 file changed, 3 insertions(+), 2 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index b3e6f5b..e3711e0 100755
--- a/pwb.py
+++ b/pwb.py
@@ -321,8 +321,6 @@
def main():
"""Command line entry point."""
global filename
- if not filename:
- return False
if global_args: # don't use sys.argv
unknown_args = pwb.handle_args(global_args)
@@ -332,6 +330,9 @@
', '.join(unknown_args)))
return False
+ if not filename:
+ return False
+
file_package = None
argvu = pwb.argvu[1:]
--
To view, visit https://gerrit.wikimedia.org/r/600941
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: I9524c1f1a95a0db21e94a5875831ef4f4f039b3d
Gerrit-Change-Number: 600941
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/598255 )
Change subject: [doc] Update ROADMAP.rst
......................................................................
[doc] Update ROADMAP.rst
Change-Id: I4e07104cac879f187e16893904c51e6c7257708e
---
M ROADMAP.rst
1 file changed, 4 insertions(+), 0 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 494f927..2a23552 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -2,6 +2,10 @@
~~~~~~~~~~~~~~~
* Usage of SkipPageError with BaseBot has been removed
+* Throttle requests after ratelimits exceeded (T253180)
+* Make Pywikibot daemon logs unexecutable (T253472)
+* Check for missing generator after BaseBot.setup() call
+* Do not change usernames when creating a Site (T253127)
* pagegenerators: handle protocols in -weblink (T251308, T251310)
* Bugfixes and improvements
* Localisation updates
--
To view, visit https://gerrit.wikimedia.org/r/598255
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: I4e07104cac879f187e16893904c51e6c7257708e
Gerrit-Change-Number: 598255
Gerrit-PatchSet: 4
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/595278 )
Change subject: [cleanup] Remove desupported SkipPageError exception handling
......................................................................
[cleanup] Remove desupported SkipPageError exception handling
Change-Id: I4f94b197271711390abde9f12ccc1b0369762aee
---
M ROADMAP.rst
M pywikibot/bot.py
2 files changed, 2 insertions(+), 32 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
Huji: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index ea8d2b0..ba37671 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,6 +1,7 @@
Current release
~~~~~~~~~~~~~~~
+* Usage of SkipPageError with BaseBot has been removed
* pagegenerators: handle protocols in -weblink (T251308, T251310)
* Bugfixes and improvements
@@ -9,7 +10,6 @@
* 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
-* 3.0.20200405: Usage of SkipPageError with BaseBot will be removed
* 3.0.20200326: Functions dealing with stars list will be removed
* 3.0.20200306: Support of MediaWiki releases below 1.19 will be dropped (T245350)
* 3.0.20200306: tools.ip will be dropped in favour of tools.is_IP (T243171)
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 4d1cfcc..93a9376 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -215,21 +215,6 @@
"""
-# It's not possible to use pywikibot.exceptions.PageRelatedError as that is
-# importing pywikibot.data.api which then needs pywikibot.bot
-class SkipPageError(Exception):
-
- """Skipped page in run."""
-
- message = 'Page "{0}" skipped due to {1}.'
-
- def __init__(self, page, reason):
- """Initializer."""
- super(SkipPageError, self).__init__(self.message.format(page, reason))
- self.reason = reason
- self.page = page
-
-
class UnhandledAnswer(Exception):
"""The given answer didn't suffice."""
@@ -1398,22 +1383,7 @@
try:
for item in self.generator:
# preprocessing of the page
- try:
- initialized_page = self.init_page(item)
- except SkipPageError as e:
- issue_deprecation_warning('Use of SkipPageError',
- 'BaseBot.skip_page() method',
- warning_class=FutureWarning,
- since='20180522')
- pywikibot.warning('Skipped "{0}" due to: {1}'.format(
- item, e.reason))
- if PY2:
- # Python 2 does not clear the exception and it may seem
- # that the generator stopped due to an exception
- sys.exc_clear()
- self._skip_counter += 1
- continue
-
+ initialized_page = self.init_page(item)
if initialized_page is None:
issue_deprecation_warning(
'Returning None from init_page() method',
--
To view, visit https://gerrit.wikimedia.org/r/595278
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: I4f94b197271711390abde9f12ccc1b0369762aee
Gerrit-Change-Number: 595278
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/598510 )
Change subject: [IMPR] Check for request.status first
......................................................................
[IMPR] Check for request.status first
First check for request.status and raise the related exception.
Finally raise the exception from request layer
Bug: T253236
Change-Id: I7edc0dab6de2ad4254494161ffdecc139606002a
---
M pywikibot/comms/http.py
1 file changed, 4 insertions(+), 5 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 2051afd..fd32330 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -398,17 +398,16 @@
if SSL_CERT_VERIFY_FAILED_MSG in str(request.data):
raise FatalServerError(str(request.data))
- # if all else fails
- if isinstance(request.data, Exception):
- error('An error occurred for uri ' + request.uri)
- raise request.data
-
if request.status == 504:
raise Server504Error('Server %s timed out' % request.hostname)
if request.status == 414:
raise Server414Error('Too long GET request')
+ if isinstance(request.data, Exception):
+ error('An error occurred for uri ' + request.uri)
+ raise request.data
+
# HTTP status 207 is also a success status for Webdav FINDPROP,
# used by the version module.
if request.status not in (200, 207):
--
To view, visit https://gerrit.wikimedia.org/r/598510
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: I7edc0dab6de2ad4254494161ffdecc139606002a
Gerrit-Change-Number: 598510
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/599305 )
Change subject: Drop redundant code
......................................................................
Drop redundant code
The same routine happens in Claim.on_item.setter,
so it's redundant to do it again.
Change-Id: If36a5072a4b3582ca5eafe2d48b50dd5960fa960
---
M pywikibot/page/__init__.py
1 file changed, 0 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 9d46cc3..9085f15 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -4616,13 +4616,6 @@
'The provided Claim instance is already used in an entity')
self.repo.addClaim(self, claim, bot=bot, **kwargs)
claim.on_item = self
- for snaks in claim.qualifiers.values():
- for snak in snaks:
- snak.on_item = self
- for source in claim.sources:
- for snaks in source.values():
- for snak in snaks:
- snak.on_item = self
def removeClaims(self, claims, **kwargs):
"""
--
To view, visit https://gerrit.wikimedia.org/r/599305
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: If36a5072a4b3582ca5eafe2d48b50dd5960fa960
Gerrit-Change-Number: 599305
Gerrit-PatchSet: 1
Gerrit-Owner: 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/598743 )
Change subject: [IMPR] Let Python 3 be the default
......................................................................
[IMPR] Let Python 3 be the default
use input instead of raw_input inside the script.
For Python redefine the function to the old raw_input
Change-Id: I35fcd6233214ca8e230ebf1a2e3e508de7f06220
---
M generate_family_file.py
1 file changed, 9 insertions(+), 9 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_family_file.py b/generate_family_file.py
index 412a676..efaa5a1 100755
--- a/generate_family_file.py
+++ b/generate_family_file.py
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
"""This script generates a family file from a given URL."""
#
-# (C) Pywikibot team, 2010-2019
+# (C) Pywikibot team, 2010-2020
#
# Distributed under the terms of the MIT license
#
@@ -19,8 +19,8 @@
# creating & retrieving urls
if sys.version_info[0] > 2:
from urllib.parse import urlparse
- raw_input = input
-else:
+else: # Python 2
+ input = raw_input # noqa: F821
from urlparse import urlparse
@@ -37,9 +37,9 @@
self.Wiki = _import_with_no_user_config(
'pywikibot.site_detect').site_detect.MWSite
if url is None:
- url = raw_input('Please insert URL to wiki: ')
+ url = input('Please insert URL to wiki: ')
if name is None:
- name = raw_input('Please insert a short name (eg: freeciv): ')
+ name = input('Please insert a short name (eg: freeciv): ')
self.dointerwiki = dointerwiki
self.base_url = url
self.name = name
@@ -82,7 +82,7 @@
if len(self.langs) > 1:
if self.dointerwiki is None:
- makeiw = raw_input(
+ makeiw = input(
'\nThere are %i languages available.'
'\nDo you want to generate interwiki links? '
'This might take a long time. ([y]es/[N]o/[e]dit)'
@@ -96,7 +96,7 @@
elif makeiw == 'e':
for wiki in self.langs:
print(wiki['prefix'], wiki['url'])
- do_langs = raw_input('Which languages do you want: ')
+ do_langs = input('Which languages do you want: ')
self.langs = [wiki for wiki in self.langs
if wiki['prefix'] in do_langs
or wiki['url'] == w.iwpath]
@@ -124,8 +124,8 @@
print('Writing %s... ' % fn)
try:
open(fn)
- if raw_input('%s already exists. Overwrite? (y/n)'
- % fn).lower() == 'n':
+ if input('{} already exists. Overwrite? (y/n)'
+ .format(fn)).lower() == 'n':
print('Terminating.')
sys.exit(1)
except IOError: # file not found
--
To view, visit https://gerrit.wikimedia.org/r/598743
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: I35fcd6233214ca8e230ebf1a2e3e508de7f06220
Gerrit-Change-Number: 598743
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
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/598467 )
Change subject: [cleanup] Do not import pathlib twice
......................................................................
[cleanup] Do not import pathlib twice
- import Path from pathlib only once. pathlib is mandatory for pwb anyway.
- Change script's doc string that it can be reused if pwb.py is not used
in directory mode but from side package too which will be implemented
soon.
Change-Id: Ia57f6a437bc8cab4dacbe86cd6ecbb54649e7178
---
M pwb.py
M tests/pwb_tests.py
2 files changed, 14 insertions(+), 18 deletions(-)
Approvals:
Huji: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index c1c24a9..f3e7d85 100755
--- a/pwb.py
+++ b/pwb.py
@@ -1,16 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-"""Wrapper script to use Pywikibot in 'directory' mode.
+"""Wrapper script to invoke pywikibot-based scripts.
-Run scripts using:
+Run scripts with pywikibot in directory mode using:
python pwb.py <pwb options> <name_of_script> <options>
-and it will use the package directory to store all user files, will fix up
-search paths so the package does not need to be installed, etc.
+This wrapper script uses the package directory to store all user files,
+will fix up search paths so the package does not need to be installed, etc.
Currently <pwb options> are global options. This can be used for tests
-to set the default site like (see T216825):
+to set the default site (see T216825):
python pwb.py -lang:de bot_tests -v
"""
@@ -33,6 +33,12 @@
PYTHON_VERSION = sys.version_info[:3]
PY2 = (PYTHON_VERSION[0] == 2)
+if not PY2:
+ from pathlib import Path
+else:
+ from pathlib2 import Path
+
+
VERSIONS_REQUIRED_MESSAGE = """
Pywikibot is not available on:
{version}
@@ -162,10 +168,6 @@
import pkg_resources
if script:
from setup import script_deps
- try:
- from pathlib import Path
- except ImportError: # Python 2
- from pathlib2 import Path
dependencies = script_deps.get(Path(script).name, [])
else:
from setup import dependencies
@@ -240,11 +242,6 @@
print('Now, you have to re-execute the command to start your script.')
sys.exit(1)
-try:
- from pathlib import Path
-except ImportError: # Python 2
- from pathlib2 import Path
-
def find_alternates(filename, script_paths):
"""Search for similar filenames in the given script paths."""
diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py
index cac124f..ab653d3 100644
--- a/tests/pwb_tests.py
+++ b/tests/pwb_tests.py
@@ -7,7 +7,7 @@
https://bitbucket.org/ned/coveragepy/src/default/tests/test_execfile.py
"""
#
-# (C) Pywikibot team, 2007-2019
+# (C) Pywikibot team, 2007-2020
#
# Distributed under the terms of the MIT license.
#
@@ -79,9 +79,8 @@
def test_script_found(self):
"""Test pwb.py script call which is found."""
stdout = io.StringIO(execute_pwb(['pwb'])['stdout'])
- self.assertEqual(
- stdout.readline().strip(),
- "Wrapper script to use Pywikibot in 'directory' mode.")
+ self.assertEqual(stdout.readline().strip(),
+ 'Wrapper script to invoke pywikibot-based scripts.')
def test_script_not_found(self):
"""Test pwbot.py script call which is not found."""
--
To view, visit https://gerrit.wikimedia.org/r/598467
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: Ia57f6a437bc8cab4dacbe86cd6ecbb54649e7178
Gerrit-Change-Number: 598467
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)