jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/824856 )
Change subject: [doc] Update some version hints
......................................................................
[doc] Update some version hints
Change-Id: Idcebe4eba4ffcae5fe797ec57fae9cfaf1f60e61
---
M ROADMAP.rst
M pywikibot/site/_generators.py
M pywikibot/textlib.py
3 files changed, 11 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 4a13866..2a9c1b8 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -7,6 +7,7 @@
Deprecations
^^^^^^^^^^^^
+* 7.6.0: :mod:`tools.itertools` datatypes should no longer imported from :mod:`pywikibot.tools`
* 7.6.0: :mod:`tools.collections` datatypes should no longer imported from :mod:`pywikibot.tools`
* 7.5.0: :mod:`pywikibot.textlib`.tzoneFixedOffset class will be removed in favour of :class:`pywikibot.time.TZoneFixedOffset`
* 7.4.0: `FilePage.usingPages()` was renamed to :meth:`using_pages()<pywikibot.FilePage.using_pages>`
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index aad1b86..021ac70 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -101,6 +101,9 @@
Pages are iterated in the same order than in the underlying pagelist.
In case of duplicates in a groupsize batch, return the first entry.
+ .. versionchanged:: 7.6
+ ``content`` parameter was added.
+
:param pagelist: an iterable that returns Page objects
:param groupsize: how many Pages to query at a time
:param templates: preload pages (typically templates) transcluded in
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index d6eab05..f8e1675 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1966,14 +1966,17 @@
return False
return True
- def timestripper(self, line):
+ def timestripper(self, line: str) -> Optional['pywikibot.Timestamp']:
"""
Find timestamp in line and convert it to time zone aware datetime.
- All the following items must be matched, otherwise None is returned:
- -. year, month, hour, time, day, minute, tzinfo
+ All the following items must be matched, otherwise None is
+ returned: -. year, month, hour, time, day, minute, tzinfo
+
+ .. versionchanged:: 7.6
+ HTML parts are removed from line
+
:return: A timestamp found on the given line
- :rtype: pywikibot.Timestamp
"""
# Try to maintain gaps that are used in _valid_date_dict_positions()
def censor_match(match):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/824856
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: Idcebe4eba4ffcae5fe797ec57fae9cfaf1f60e61
Gerrit-Change-Number: 824856
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/+/824855 )
Change subject: [7.7] Prepare next release Pywikibot 7.7
......................................................................
[7.7] Prepare next release Pywikibot 7.7
Change-Id: I8ba3aebc0544148a3b83e915b5efbbafc3f903b8
---
M .appveyor.yml
M HISTORY.rst
M ROADMAP.rst
M pywikibot/__metadata__.py
M scripts/__init__.py
5 files changed, 33 insertions(+), 26 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.appveyor.yml b/.appveyor.yml
index c11301c..75a438e 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -1,7 +1,7 @@
image: Visual Studio 2019
clone_depth: 50
skip_tags: true
-version: 7.6.{build}
+version: 7.7.{build}
environment:
PYWIKIBOT_DIR: "%appdata%\\Pywikibot"
diff --git a/HISTORY.rst b/HISTORY.rst
index 3f64ec3..1025ec1 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,6 +1,33 @@
Release history
^^^^^^^^^^^^^^^
+7.6.0
+-----
+*21 August 2022*
+
+* 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
+ in :meth:`Page.templates()<page.BasePage.templates>` (:phab:`T313736`)
+* Add support for vikidia:oc
+* Exit loop in PageFromFileReader if match.end() <= 0 (:phab:`T313684`)
+* Allow Exception as parameter of pywikibot.exceptions.Error
+* Make :func:`GoogleSearchPageGenerator<pagegenerators.GoogleSearchPageGenerator>`
+ and :func:`PetScanPageGenerator<pagegenerators.PetScanPageGenerator>` a restartable
+ Generator (:phab:`T313681`, :phab:`T313683`)
+* Provide a :class:`collections.GeneratorWrapper<tools.collections.GeneratorWrapper>`
+ class to start/restart a generator (:phab:`T301318`, :phab:`T312654`, :phab:`T312883`)
+* tools' itertools functions were moved to :mod:`tools.itertools` submodule
+* tools' collections classes were moved to :mod:`tools.collections` submodule
+* Set successful login status for the OAuth case (:phab:`T313571`)
+
+
7.5.0
-----
*22 July 2022*
@@ -88,7 +115,7 @@
* `use_disambig` BaseBot attribute was added to hande disambig skipping
* Deprecate RedirectPageBot and NoRedirectPageBot in favour of `use_redirects` attribute
* tools.formatter.color_format is deprecated and will be removed
-* A new and easier color format was implemented; colors can be used like:
+* A new and easier color format was implemented; colors can be used like:
``'this is a <<green>>colored<<default>> text'``
* Unused and unsupported `xmlreader.XmlParserThread` was removed
* Use upercased IP user titles (:phab:`T306291`)
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 0add0c8..4a13866 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,27 +1,7 @@
-Current release 7.6.0
+Current release 7.7.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
- in :meth:`Page.templates()<page.BasePage.templates>` (:phab:`T313736`)
-* Add support for vikidia:oc
-* Exit loop in PageFromFileReader if match.end() <= 0 (:phab:`T313684`)
-* Allow Exception as parameter of pywikibot.exceptions.Error
-* Make :func:`GoogleSearchPageGenerator<pagegenerators.GoogleSearchPageGenerator>`
- and :func:`PetScanPageGenerator<pagegenerators.PetScanPageGenerator>` a restartable
- Generator (:phab:`T313681`, :phab:`T313683`)
-* Provide a :class:`collections.GeneratorWrapper<tools.collections.GeneratorWrapper>`
- class to start/restart a generator (:phab:`T301318`, :phab:`T312654`, :phab:`T312883`)
-* tools' itertools functions were moved to :mod:`tools.itertools` submodule
-* tools' collections classes were moved to :mod:`tools.collections` submodule
-* Set successful login status for the OAuth case (:phab:`T313571`)
+*(no changes yet)*
Deprecations
diff --git a/pywikibot/__metadata__.py b/pywikibot/__metadata__.py
index d2dd282..9d6e66c 100644
--- a/pywikibot/__metadata__.py
+++ b/pywikibot/__metadata__.py
@@ -11,7 +11,7 @@
__name__ = 'pywikibot'
-__version__ = '7.6.0'
+__version__ = '7.7.0.dev0'
__description__ = 'Python MediaWiki Bot Framework'
__maintainer__ = 'The Pywikibot team'
__maintainer_email__ = 'pywikibot(a)lists.wikimedia.org'
diff --git a/scripts/__init__.py b/scripts/__init__.py
index 4ee5ede..c482795 100644
--- a/scripts/__init__.py
+++ b/scripts/__init__.py
@@ -29,4 +29,4 @@
#
# Distributed under the terms of the MIT license.
#
-__version__ = '7.6.0'
+__version__ = '7.7.0'
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/824855
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: I8ba3aebc0544148a3b83e915b5efbbafc3f903b8
Gerrit-Change-Number: 824855
Gerrit-PatchSet: 2
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/+/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