jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/480810 )
Change subject: proofreadpage_tests.py: add error text to Exception
......................................................................
proofreadpage_tests.py: add error text to Exception
Add also error text to raised Exception in case of errors during
page.ocr() call.
Main purpose it to facilitate investigations when tests fail.
Bug: T212076
Change-Id: I1c4a4da38b9f6b4f4ec0bdb90bc1e6712eb61630
---
M pywikibot/proofreadpage.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 5432d70..a075e31 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -722,7 +722,8 @@
if not error:
return text
else:
- raise ValueError('%s: not possible to perform OCR.' % self)
+ raise ValueError(
+ '{0}: not possible to perform OCR. {1}'.format(self, text))
class PurgeRequest(Request):
--
To view, visit https://gerrit.wikimedia.org/r/480810
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: I1c4a4da38b9f6b4f4ec0bdb90bc1e6712eb61630
Gerrit-Change-Number: 480810
Gerrit-PatchSet: 1
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(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/480076 )
Change subject: [IMPR] Use SingleSiteBot with states_redirect.py
......................................................................
[IMPR] Use SingleSiteBot with states_redirect.py
Bot class is noted as to be deprecated. Use SingleSitesBot instead.
- StatesRedirectBot.site is set by super class but the generator must become
an StatesRedirectBot property
- Create the abbrev in setup method
Change-Id: Ic061ee0d8f92033c7ec1086b26f9d1dca806f2ba
---
M scripts/states_redirect.py
1 file changed, 15 insertions(+), 12 deletions(-)
Approvals:
D3r1ck01: Looks good to me, but someone else must approve
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/states_redirect.py b/scripts/states_redirect.py
index 10802b7..18829e2 100755
--- a/scripts/states_redirect.py
+++ b/scripts/states_redirect.py
@@ -25,7 +25,7 @@
import pywikibot
-from pywikibot.bot import suggest_help
+from pywikibot.bot import SingleSiteBot, suggest_help
from pywikibot import i18n
try:
@@ -34,32 +34,35 @@
pycountry = e
-class StatesRedirectBot(pywikibot.Bot):
+class StatesRedirectBot(SingleSiteBot):
"""Bot class used for implementation of re-direction norms."""
def __init__(self, start, force):
"""Initializer.
- Parameters:
- @param start:xxx Specify the place in the alphabet to start
- searching.
- @param force: Don't ask whether to create pages, just create
- them.
+ @param start:xxx Specify the place in the alphabet to start searching.
+ @type start: str
+ @param force: Don't ask whether to create pages, just create them.
+ @type force: bool
"""
- site = pywikibot.Site()
- generator = site.allpages(start=start)
- super(StatesRedirectBot, self).__init__(generator=generator)
-
+ super(StatesRedirectBot, self).__init__()
+ self.start = start
self.force = force
- # Created abbrev from pycountry data base
+ def setup(self):
+ """Create abbrev from pycountry data base."""
self.abbrev = {}
for subd in pycountry.subdivisions:
# Used subd.code[3:] to extract the exact code for
# subdivisional states(ignoring the country code).
self.abbrev[subd.name] = subd.code[3:]
+ @property
+ def generator(self):
+ """Generator used by run() method."""
+ return self.site.allpages(start=self.start)
+
def treat(self, page):
"""Re-directing process.
--
To view, visit https://gerrit.wikimedia.org/r/480076
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: Ic061ee0d8f92033c7ec1086b26f9d1dca806f2ba
Gerrit-Change-Number: 480076
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/472864 )
Change subject: [IMPR] Allow use of action=purge API parameters
......................................................................
[IMPR] Allow use of action=purge API parameters
Add options to use forcelinkupdate, forcerecursivelinkupdate, redirects,
and converttitles.
Change-Id: I607304403ded6eedc7d89885c1aecc9fe379e25c
---
M scripts/touch.py
1 file changed, 27 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/touch.py b/scripts/touch.py
index 48ba7f6..24f5605 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -10,8 +10,17 @@
¶ms;
--purge Do not touch but purge the page
--botflag Force botflag in case of edits with changes.
+-purge Do not touch but purge the page
+
+Touch arguments:
+-botflag Force botflag in case of edits with changes.
+
+Purge arguments:
+-converttitles Convert titles to other variants if necessary
+-forcelinkupdate Update the links tables
+-forcerecursivelinkupdate Update the links table, and update the links tables
+ for any page that uses this page as a template
+-redirects Automatically resolve redirects
"""
#
@@ -62,10 +71,22 @@
"""Purge each page on the generator."""
+ def __init__(self, generator, **kwargs):
+ """Initialize a PurgeBot instance with the options and generator."""
+ self.availableOptions = {
+ 'converttitles': None,
+ 'forcelinkupdate': None,
+ 'forcerecursivelinkupdate': None,
+ 'redirects': None
+ }
+ super(PurgeBot, self).__init__(generator=generator, **kwargs)
+
def treat(self, page):
"""Purge the given page."""
pywikibot.output('Page {0}{1} purged'.format(
- page.title(as_link=True), '' if page.purge() else ' not'))
+ page.title(as_link=True),
+ '' if page.purge(**self.options) else ' not'
+ ))
def main(*args):
@@ -86,14 +107,15 @@
bot_class = TouchBot
for arg in local_args:
+ if gen_factory.handleArg(arg):
+ continue
if arg == '-purge':
bot_class = PurgeBot
elif arg == '-redir':
issue_deprecation_warning(
'\n-redir', None, 1, ArgumentDeprecationWarning,
since='20150514')
- elif not gen_factory.handleArg(arg) and arg.startswith('-'):
- # -botflag
+ elif arg.startswith('-'):
options[arg[1:].lower()] = True
gen = gen_factory.getCombinedGenerator(preload=True)
--
To view, visit https://gerrit.wikimedia.org/r/472864
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: I607304403ded6eedc7d89885c1aecc9fe379e25c
Gerrit-Change-Number: 472864
Gerrit-PatchSet: 7
Gerrit-Owner: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: D3r1ck01 <alangiderick(a)gmail.com>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/478641 )
Change subject: [doc] Fix task number of T57185
......................................................................
[doc] Fix task number of T57185
Change-Id: I1ccb702ae88cbf5887efb6349f9b38c14d367edc
---
M pywikibot/cosmetic_changes.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 327d7a2..85ff485 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -990,7 +990,7 @@
# FIXME: split this function into two.
# replace persian/arabic digits
- # deactivated due to bug 55185
+ # deactivated due to bug T57185
for i in range(0, 10):
text = textlib.replaceExcept(text, old[i], new[i], exceptions)
# do not change digits in class, style and table params
--
To view, visit https://gerrit.wikimedia.org/r/478641
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: I1ccb702ae88cbf5887efb6349f9b38c14d367edc
Gerrit-Change-Number: 478641
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
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/423237 )
Change subject: [bugfix] Use python specific api cache paths in cache maintenance script
......................................................................
[bugfix] Use python specific api cache paths in cache maintenance script
- use python version specific api cache paths
- use os.path.join to concat paths
- don't restore the api cache entry if deletion is wanted only
- skip cache path if version does not match
- use pywikibot.handle_args instead of the deprecated variant
Bug: T183911
Change-Id: Idf7bcf8b8ecefc5fc3979bb2aa4c7cf4b67d63fc
---
M scripts/maintenance/cache.py
1 file changed, 28 insertions(+), 6 deletions(-)
Approvals:
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/cache.py b/scripts/maintenance/cache.py
index 445a277..8215d2c 100755
--- a/scripts/maintenance/cache.py
+++ b/scripts/maintenance/cache.py
@@ -78,6 +78,8 @@
from pywikibot.page import User
from pywikibot.site import APISite, DataSite, LoginStatus
+from pywikibot.tools import PYTHON_VERSION
+
__all__ = (
'User', 'APISite', 'DataSite', 'LoginStatus',
'ParseError', 'CacheEntry', 'process_entries', 'main',
@@ -232,7 +234,8 @@
- True = always use
"""
if not cache_path:
- cache_path = os.path.join(pywikibot.config2.base_dir, 'apicache')
+ cache_path = os.path.join(pywikibot.config2.base_dir,
+ 'apicache-py{0:d}'.format(PYTHON_VERSION[0]))
if not os.path.exists(cache_path):
pywikibot.error('%s: no such file or directory' % cache_path)
@@ -251,6 +254,21 @@
stinfo = os.stat(filepath)
entry = CacheEntry(cache_dir, filename)
+
+ # Deletion is choosen only, abbreviate this request
+ if func is None and output_func is None \
+ and action_func == CacheEntry._delete:
+ action_func(entry)
+ continue
+
+ # Skip foreign python specific directory
+ _, _, version = cache_path.partition('-')
+ if version and version[-1] != str(PYTHON_VERSION[0]):
+ pywikibot.error(
+ "Skipping {0} directory, can't read content with python {1[0]}"
+ .format(cache_path, PYTHON_VERSION))
+ continue
+
try:
entry._load_cache()
except ValueError as e:
@@ -387,7 +405,7 @@
def main():
"""Process command line arguments and invoke bot."""
- local_args = pywikibot.handleArgs()
+ local_args = pywikibot.handle_args()
cache_paths = None
delete = False
command = None
@@ -419,17 +437,21 @@
cache_paths.append(arg)
if not cache_paths:
- cache_paths = ['apicache', 'tests/apicache']
+ folders = ('apicache', 'apicache-py2', 'apicache-py3')
+ cache_paths = list(folders)
+ # Add tests folders
+ cache_paths += [os.path.join('tests', f) for f in folders]
# Also process the base directory, if it isnt the current directory
if os.path.abspath(os.getcwd()) != pywikibot.config2.base_dir:
cache_paths += [
- os.path.join(pywikibot.config2.base_dir, 'apicache')]
+ os.path.join(pywikibot.config2.base_dir, f) for f in folders]
# Also process the user home cache, if it isnt the config directory
- if os.path.expanduser('~/.pywikibot') != pywikibot.config2.base_dir:
+ userpath = os.path.expanduser(os.path.join('~', '.pywikibot'))
+ if userpath != pywikibot.config2.base_dir:
cache_paths += [
- os.path.join(os.path.expanduser('~/.pywikibot'), 'apicache')]
+ os.path.join(userpath, f) for f in folders]
if delete:
action_func = CacheEntry._delete
--
To view, visit https://gerrit.wikimedia.org/r/423237
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: Idf7bcf8b8ecefc5fc3979bb2aa4c7cf4b67d63fc
Gerrit-Change-Number: 423237
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)