jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/824816 )
Change subject: [doc] Update ROADMAP.rst and CHANGELOG.rst
......................................................................
[doc] Update ROADMAP.rst and CHANGELOG.rst
Change-Id: I095548acdbd1cdc8dfcbaf8067ee18dd7d7c489c
---
M ROADMAP.rst
M scripts/CHANGELOG.rst
2 files changed, 9 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 806b446..0add0c8 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,6 +1,12 @@
Current release 7.6.0
^^^^^^^^^^^^^^^^^^^^^
+* Add support for pcmwiki, guvwikt and bjnwikt (:phab:`T309059`, :phab:`T310882`, :phab:`T312217`)
+* support *not* loading text :meth:`site.APISite.preloadpages` (:phab:`T67163`)
+* :func:`textlib.TimeStripper.timestripper` removes HTML elements before searching for
+ timestamp in text (:phab:`T302496`)
+* backport :mod:`backports.pairwise()<backports>` from Python 3.10
+* L10N updates
* Fix partial caching in :meth:`Category.subcategories()<page.Category.subcategories>` (:phab:`T88217`)
* Method :meth:`Page.has_content()<page.BasePage.has_content>` was added (:phab:`T313736`)
* Discard cache and reload it if cache was loaded without content and content is required
diff --git a/scripts/CHANGELOG.rst b/scripts/CHANGELOG.rst
index 9169144..165f1a1 100644
--- a/scripts/CHANGELOG.rst
+++ b/scripts/CHANGELOG.rst
@@ -9,6 +9,9 @@
archivebot
~~~~~~~~~~
+* use ``User:MiszaBot/config`` as default template
+* raise MalformedConfigError if 'maxarchivesize' is 0 (:phab:`T313886`)
+* Preserve thread order in archive even if threads are archived later (:phab:`T312773`, :phab:`T314560`)
* Skip the page if it does not exist
* Fix for DiscussionPage.size() (:phab:`T313886`)
* Decrease memory usage and improve processing speed
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/824816
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: I095548acdbd1cdc8dfcbaf8067ee18dd7d7c489c
Gerrit-Change-Number: 824816
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.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/+/823686 )
Change subject: [IMPR] use tools.itertools.itergroup to iterate pairs of elements
......................................................................
[IMPR] use tools.itertools.itergroup to iterate pairs of elements
Also add a strict parameter to itergroup function; if True a ValueError
is raised if length of iterable is not divisible by size.
Change-Id: I815f5011dde9aa77a974b189ba60eaf277a1cd8c
---
M pywikibot/tools/itertools.py
M scripts/claimit.py
M scripts/replace.py
M scripts/template.py
4 files changed, 40 insertions(+), 22 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/itertools.py b/pywikibot/tools/itertools.py
index 397453f..7d8547d 100644
--- a/pywikibot/tools/itertools.py
+++ b/pywikibot/tools/itertools.py
@@ -1,4 +1,8 @@
-"""Iterator functions."""
+"""Iterator functions.
+
+.. note:: ``pairwise()`` function introduced in Python 3.10 is backported
+ in :mod:`backports`
+"""
#
# (C) Pywikibot team, 2008-2022
#
@@ -9,21 +13,25 @@
from contextlib import suppress
from itertools import chain, zip_longest
+from typing import Any
+from pywikibot.backports import Generator
from pywikibot.logging import debug
from pywikibot.tools import issue_deprecation_warning
__all__ = (
- 'itergroup',
- 'islice_with_ellipsis',
- 'intersect_generators',
- 'roundrobin_generators',
'filter_unique',
+ 'intersect_generators',
+ 'islice_with_ellipsis',
+ 'itergroup',
+ 'roundrobin_generators',
)
-def itergroup(iterable, size: int):
+def itergroup(iterable,
+ size: int,
+ strict: bool = False) -> Generator[Any, None, None]:
"""Make an iterator that returns lists of (up to) size items from iterable.
Example:
@@ -39,6 +47,11 @@
Traceback (most recent call last):
...
StopIteration
+
+ :param size: How many items of the iterable to get in one chunk
+ :param strict: If True, raise a ValueError if length of iterable is
+ not divisible by `size`.
+ :raises ValueError: iterable is not divisible by size
"""
group = []
for item in iterable:
@@ -47,6 +60,8 @@
yield group
group = []
if group:
+ if strict:
+ raise ValueError('iterable is not divisible by size.')
yield group
@@ -192,7 +207,7 @@
return
-def roundrobin_generators(*iterables):
+def roundrobin_generators(*iterables) -> Generator[Any, None, None]:
"""Yield simultaneous from each iterable.
Sample:
diff --git a/scripts/claimit.py b/scripts/claimit.py
index 3e1ac09..5bddc26 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -52,6 +52,7 @@
#
import pywikibot
from pywikibot import WikidataBot, pagegenerators
+from pywikibot.tools.itertools import itergroup
# This is required for the text that is shown when you run this script
@@ -126,15 +127,15 @@
claims = []
repo = pywikibot.Site().data_repository()
- for i in range(0, len(commandline_claims), 2):
- claim = pywikibot.Claim(repo, commandline_claims[i])
+ for property_id, target_str in itergroup(commandline_claims, 2):
+ claim = pywikibot.Claim(repo, property_id)
if claim.type == 'wikibase-item':
- target = pywikibot.ItemPage(repo, commandline_claims[i + 1])
+ target = pywikibot.ItemPage(repo, target_str)
elif claim.type == 'string':
- target = commandline_claims[i + 1]
+ target = target_str
elif claim.type == 'globe-coordinate':
coord_args = [
- float(c) for c in commandline_claims[i + 1].split(',')]
+ float(c) for c in target_str.split(',')]
if len(coord_args) >= 3:
precision = coord_args[2]
else:
diff --git a/scripts/replace.py b/scripts/replace.py
index ac97270..cdc730c 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -158,6 +158,7 @@
from pywikibot.bot import ExistingPageBot, SingleSiteBot
from pywikibot.exceptions import InvalidPageError, NoPageError
from pywikibot.tools import chars
+from pywikibot.tools.itertools import itergroup
# This is required for the text that is shown when you run this script
@@ -979,9 +980,8 @@
# The summary stored here won't be actually used but is only an example
site = pywikibot.Site()
single_summary = None
- for i in range(0, len(commandline_replacements), 2):
- replacement = Replacement(commandline_replacements[i],
- commandline_replacements[i + 1])
+ for old, new in itergroup(commandline_replacements, 2):
+ replacement = Replacement(old, new)
if not single_summary:
single_summary = i18n.twtranslate(
site, 'replace-replacing',
diff --git a/scripts/template.py b/scripts/template.py
index 7e83f71..9fc88f0 100755
--- a/scripts/template.py
+++ b/scripts/template.py
@@ -115,7 +115,12 @@
from pywikibot import i18n, pagegenerators, textlib
from pywikibot.bot import SingleSiteBot
from pywikibot.pagegenerators import XMLDumpPageGenerator
-from pywikibot.tools.itertools import filter_unique, roundrobin_generators
+from pywikibot.tools.itertools import (
+ filter_unique,
+ itergroup,
+ roundrobin_generators,
+)
+
from scripts.replace import ReplaceRobot as ReplaceBot
@@ -215,7 +220,6 @@
:param args: command line arguments
"""
template_names = []
- templates = {}
options = {}
# If xmlfilename is None, references will be loaded from the live wiki.
xmlfilename = None
@@ -266,13 +270,11 @@
return
if bool(options.get('subst', False)) ^ options.get('remove', False):
- for template_name in template_names:
- templates[template_name] = None
+ templates = dict.fromkeys(template_names)
else:
try:
- for i in range(0, len(template_names), 2):
- templates[template_names[i]] = template_names[i + 1]
- except IndexError:
+ templates = dict(itergroup(template_names, 2, strict=True))
+ except ValueError:
pywikibot.output('Unless using solely -subst or -remove, '
'you must give an even number of template names.')
return
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/823686
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: I815f5011dde9aa77a974b189ba60eaf277a1cd8c
Gerrit-Change-Number: 823686
Gerrit-PatchSet: 4
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: 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/+/822083 )
Change subject: [doc] Document -inverse argument with an example
......................................................................
[doc] Document -inverse argument with an example
Bug: T314889
Change-Id: I71c491fdff6a4ba9a990a3dc205f586c027798ad
---
M scripts/harvest_template.py
1 file changed, 28 insertions(+), 17 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index b85f714..54552af 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -48,48 +48,59 @@
Examples
--------
-This will try to import existing images from "image" parameter of "Infobox
-person" on English Wikipedia as Wikidata property "P18" (image):
+The following command will try to import existing images from "image"
+parameter of "Infobox person" on English Wikipedia as Wikidata property
+"P18" (image):
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
-template:"Infobox person" image P18
-This will behave the same as the previous example and also try to import
-[[links]] from "birth_place" parameter of the same template as Wikidata
-property "P19" (place of birth):
+The following command will behave the same as the previous example and also
+try to import [[links]] from "birth_place" parameter of the same template
+as Wikidata property "P19" (place of birth):
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
-template:"Infobox person" image P18 birth_place P19
-This will import both "birth_place" and "death_place" params with -islink
-modifier, ie. the bot will try to import values, even if it doesn't find
-a [[link]]:
+The following command will import both "birth_place" and "death_place"
+params with -islink modifier, ie. the bot will try to import values, even
+if it doesn't find a [[link]]:
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
-template:"Infobox person" -islink birth_place P19 death_place P20
-This will do the same but only "birth_place" can be imported without a link:
+The following command will do the same but only "birth_place" can be
+imported without a link:
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
-template:"Infobox person" birth_place P19 -islink death_place P20
-This will import an occupation from "occupation" parameter of "Infobox
-person" on English Wikipedia as Wikidata property "P106" (occupation). The
-page won't be skipped if the item already has that property but there is
-not the new value:
+The following command will import an occupation from "occupation" parameter
+of "Infobox person" on English Wikipedia as Wikidata property "P106"
+(occupation). The page won't be skipped if the item already has that
+property but there is not the new value:
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
-template:"Infobox person" occupation P106 -exists:p
-This will import band members from the "current_members" parameter of "Infobox
-musical artist" on English Wikipedia as Wikidata property "P527" (has
-part). This will only extract multiple band members if each is linked, and
-will not add duplicate claims for the same member:
+The following command will import band members from the "current_members"
+parameter of "Infobox musical artist" on English Wikipedia as Wikidata
+property "P527" (has part). This will only extract multiple band members
+if each is linked, and will not add duplicate claims for the same member:
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
-template:"Infobox musical artist" current_members P527 -exists:p \
-multi
+The following command will import the category's main topic from the first
+anonymous parameter of "Cat main" on English Wikipedia as Wikidata property
+"P301" (category's main topic) and whenever a new value is imported,
+the inverse claim is imported to the topic item as Wikidata property "P910"
+(topic's main category) unless a claim of that property is already there:
+
+ python pwb.py harvest_template -lang:en -family:wikipedia -namespace:14 \
+ -template:"Cat main" 1 P301 -inverse:P910 -islink
+
.. note:: This script is a
:py:obj:`ConfigParserBot <bot.ConfigParserBot>`. All options
can be set within a settings file which is scripts.ini by default.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/822083
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: I71c491fdff6a4ba9a990a3dc205f586c027798ad
Gerrit-Change-Number: 822083
Gerrit-PatchSet: 3
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(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/+/822082 )
Change subject: Fix typo
......................................................................
Fix typo
Change-Id: I5e1a98097cf2b9ef02447058af8f082adbfb8120
---
M tests/script_tests.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index cbed98f..e45d1e5 100755
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -100,7 +100,7 @@
# Some of these are not pretty, but at least they are informative
# and not backtraces starting deep in the pywikibot package.
no_args_expected_results = {
- 'archivebot': 'No template was spcified, using default',
+ 'archivebot': 'No template was specified, using default',
# TODO: until done here, remember to set editor = None in user-config.py
'change_pagelang': 'No -setlang parameter given',
'checkimages': 'Execution time: 0 seconds',
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/822082
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: I5e1a98097cf2b9ef02447058af8f082adbfb8120
Gerrit-Change-Number: 822082
Gerrit-PatchSet: 2
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(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/+/822044 )
Change subject: Revert pairwise usage in several scripts
......................................................................
Revert pairwise usage in several scripts
pairwise is overlapping which is not appropriate in these cases.
This partly reverts commit d4ab3d26ae476983cbd38829b711ceaa19aaf75b.
Change-Id: I938f703408a161f0d4f7b803c0ae0ab418a1f76c
---
M scripts/claimit.py
M scripts/replace.py
M scripts/template.py
3 files changed, 18 insertions(+), 18 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/claimit.py b/scripts/claimit.py
index 4fff795..3e1ac09 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -52,7 +52,6 @@
#
import pywikibot
from pywikibot import WikidataBot, pagegenerators
-from pywikibot.backports import pairwise
# This is required for the text that is shown when you run this script
@@ -127,15 +126,15 @@
claims = []
repo = pywikibot.Site().data_repository()
- for source_str, target_str in pairwise(commandline_claims):
- claim = pywikibot.Claim(repo, source_str)
+ for i in range(0, len(commandline_claims), 2):
+ claim = pywikibot.Claim(repo, commandline_claims[i])
if claim.type == 'wikibase-item':
- target = pywikibot.ItemPage(repo, target_str)
+ target = pywikibot.ItemPage(repo, commandline_claims[i + 1])
elif claim.type == 'string':
- target = target_str
+ target = commandline_claims[i + 1]
elif claim.type == 'globe-coordinate':
coord_args = [
- float(c) for c in target_str.split(',')]
+ float(c) for c in commandline_claims[i + 1].split(',')]
if len(coord_args) >= 3:
precision = coord_args[2]
else:
diff --git a/scripts/replace.py b/scripts/replace.py
index 703dd5c..ac97270 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -154,7 +154,7 @@
import pywikibot
from pywikibot import editor, fixes, i18n, pagegenerators, textlib
-from pywikibot.backports import pairwise, Dict, Generator, List, Pattern, Tuple
+from pywikibot.backports import Dict, Generator, List, Pattern, Tuple
from pywikibot.bot import ExistingPageBot, SingleSiteBot
from pywikibot.exceptions import InvalidPageError, NoPageError
from pywikibot.tools import chars
@@ -979,9 +979,9 @@
# The summary stored here won't be actually used but is only an example
site = pywikibot.Site()
single_summary = None
-
- for old, new in pairwise(commandline_replacements):
- replacement = Replacement(old, new)
+ for i in range(0, len(commandline_replacements), 2):
+ replacement = Replacement(commandline_replacements[i],
+ commandline_replacements[i + 1])
if not single_summary:
single_summary = i18n.twtranslate(
site, 'replace-replacing',
diff --git a/scripts/template.py b/scripts/template.py
index 58421bd..7e83f71 100755
--- a/scripts/template.py
+++ b/scripts/template.py
@@ -113,7 +113,6 @@
import pywikibot
from pywikibot import i18n, pagegenerators, textlib
-from pywikibot.backports import pairwise
from pywikibot.bot import SingleSiteBot
from pywikibot.pagegenerators import XMLDumpPageGenerator
from pywikibot.tools.itertools import filter_unique, roundrobin_generators
@@ -216,6 +215,7 @@
:param args: command line arguments
"""
template_names = []
+ templates = {}
options = {}
# If xmlfilename is None, references will be loaded from the live wiki.
xmlfilename = None
@@ -266,16 +266,17 @@
return
if bool(options.get('subst', False)) ^ options.get('remove', False):
- templates = {name: None for name in template_names}
+ for template_name in template_names:
+ templates[template_name] = None
else:
- if len(template_names) % 2:
- pywikibot.warning('Unless using solely -subst or -remove, you'
- 'must give an even number of template names.')
+ try:
+ for i in range(0, len(template_names), 2):
+ templates[template_names[i]] = template_names[i + 1]
+ except IndexError:
+ pywikibot.output('Unless using solely -subst or -remove, '
+ 'you must give an even number of template names.')
return
- templates = {key: value
- for key, value in pairwise(template_names)}
-
old_templates = [pywikibot.Page(site, template_name, ns=10)
for template_name in templates]
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/822044
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: I938f703408a161f0d4f7b803c0ae0ab418a1f76c
Gerrit-Change-Number: 822044
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged