jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1361164?usp=email )
Change subject: pagegenerators: Remove the deprecated logevents total argument
......................................................................
pagegenerators: Remove the deprecated logevents total argument
The third value of -logevents was deprecated as a result count in
Pywikibot 9.2 and is scheduled for removal in Pywikibot 12. Parse it
only as a start timestamp and leave result limiting to -limit.
Remove the count parsing and warning, update the option documentation,
and adapt the existing legacy-count test to check rejection offline.
Bug: T128981
Change-Id: Id599cb55381fd556fadbf83daa6d63a79dac979c
---
M ROADMAP.rst
M pywikibot/pagegenerators/__init__.py
M pywikibot/pagegenerators/_factory.py
M tests/pagegenerators_tests.py
4 files changed, 23 insertions(+), 53 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 1864c8f..72fefb0 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -47,8 +47,6 @@
-------------------------------
* 9.2.0: Imports of :mod:`logging` functions from the :mod:`bot` module are
deprecated and will be desupported
-* 9.2.0: *total* argument in ``-logevents`` pagegenerators option is
deprecated;
- use ``-limit`` instead (:phab:`T128981`)
* 9.0.0: The *content* parameter of :meth:`proofreadpage.IndexPage.page_gen`
is deprecated and will be
ignored (:phab:`T358635`)
diff --git a/pywikibot/pagegenerators/__init__.py
b/pywikibot/pagegenerators/__init__.py
index 9f66519..dcc9d4d 100644
--- a/pywikibot/pagegenerators/__init__.py
+++ b/pywikibot/pagegenerators/__init__.py
@@ -214,10 +214,9 @@
logevent,username,start,end
- .. version-deprecated:: 9.2
- backward compatible *total* argument like
- ``logevent,username,total``; use ``-limit`` filter
- option instead (see below).
+ .. version-removed:: 12.0
+ The *total* argument in ``logevent,username,total``.
+ Use the ``-limit`` filter option instead (see below).
To use the default value, use an empty string.
diff --git a/pywikibot/pagegenerators/_factory.py
b/pywikibot/pagegenerators/_factory.py
index 6103ff4..0ea0450 100644
--- a/pywikibot/pagegenerators/_factory.py
+++ b/pywikibot/pagegenerators/_factory.py
@@ -19,10 +19,7 @@
from pywikibot import i18n
from pywikibot.bot import ShowingListOption
from pywikibot.data import api
-from pywikibot.exceptions import (
- ArgumentDeprecationWarning,
- UnknownExtensionError,
-)
+from pywikibot.exceptions import UnknownExtensionError
from pywikibot.pagegenerators._filters import (
CategoryFilterPageGenerator,
ItemClaimFilterPageGenerator,
@@ -52,7 +49,7 @@
WikibaseSearchItemPageGenerator,
WikidataSPARQLPageGenerator,
)
-from pywikibot.tools import issue_deprecation_warning, strtobool
+from pywikibot.tools import strtobool
from pywikibot.tools.collections import DequeGenerator
from pywikibot.tools.itertools import (
filter_unique,
@@ -412,8 +409,9 @@
) -> Iterable[pywikibot.page.BasePage] | None:
"""Parse the -logevent argument information.
- .. version-deprecated:: 9.2
- the *start* parameter as total amount of pages.
+ .. version-removed:: 12.0
+ The *start* parameter as total amount of pages. Use ``-limit``
+ instead.
:param logtype: A valid logtype
:param user: A username associated to the log events. Ignored if
@@ -422,39 +420,17 @@
convertible into Timestamp matching '%Y%m%d%H%M%S'.
:param end: Timestamp to end listing at. This must be
convertible into a Timestamp matching '%Y%m%d%H%M%S'.
- :return: The generator or None if invalid 'start/total' or 'end'
+ :return: The generator or None if invalid 'start' or 'end'
value.
"""
- def parse_start(
- start: str | None
- ) -> tuple[pywikibot.Timestamp | None, int | None]:
- """Parse start and return (start, total)."""
- if not start:
- return None, None
-
- if len(start) >= 8:
- return pywikibot.Timestamp.fromtimestampformat(start), None
-
- instead = (f'-limit option like "-logevents:{logtype}'
- f'{"," if user else ""}{user} -limit:{start}"')
- issue_deprecation_warning('-logevents with total argument',
- instead,
- warning_class=ArgumentDeprecationWarning,
- since='9.2.0')
- return None, int(start)
-
try:
- start_, total = parse_start(start)
+ start_ = (pywikibot.Timestamp.fromtimestampformat(start)
+ if start else None)
except ValueError as err:
pywikibot.error(
f'{err}. Start parameter has wrong format!')
return None
- if total is not None and total < 0:
- pywikibot.error(f'Total number of log ({start}) events must be a'
- ' positive int.')
- return None
-
if end is None:
end_ = None
else:
@@ -472,7 +448,7 @@
# 'user or None', because user might be an empty string when
# 'foo,,bar' was used.
- return LogeventsPageGenerator(logtype, user or None, total=total,
+ return LogeventsPageGenerator(logtype, user or None,
start=start_, end=end_)
def _handle_filelinks(self, value: str) -> HANDLER_GEN_TYPE:
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 94669ed..bd8539d 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -31,7 +31,6 @@
from tests import join_data_path
from tests.aspects import (
DefaultSiteTestCase,
- DeprecationTestCase,
RecentChangesTestCase,
TestCase,
WikidataTestCase,
@@ -856,6 +855,16 @@
dry = True
+ def test_logevents_with_total(self) -> None:
+ """Reject the removed total argument without querying the wiki."""
+ with mock.patch('pywikibot.error') as error:
+ result = pagegenerators.GeneratorFactory._parse_log_events(
+ 'newusers', start='1')
+ self.assertIsNone(result)
+ error.assert_called_once()
+ self.assertIn('Start parameter has wrong format',
+ error.call_args[0][0])
+
def test_ref_includes_redirects(self) -> None:
"""Test -ref generator includes redirects before filtering."""
gf = pagegenerators.GeneratorFactory(site=self.get_site())
@@ -1935,8 +1944,7 @@
self.assertEqual(cat.site, fa_wikisource)
-class TestLogeventsFactoryGenerator(DefaultSiteTestCase,
- DeprecationTestCase):
+class TestLogeventsFactoryGenerator(DefaultSiteTestCase):
"""Test GeneratorFactory with pagegenerators.LogeventsPageGenerator."""
@@ -1989,17 +1997,6 @@
pages = set(gen)
self.assertIsEmpty(pages)
- def test_logevents_with_total(self) -> None:
- """Test -logevents which uses total."""
- gf = pagegenerators.GeneratorFactory(site=self.site)
- self.assertTrue(gf.handle_arg('-logevents:newusers,,1'))
- gen = gf.getCombinedGenerator()
- self.assertIsNotNone(gen)
- pages = set(gen)
- self.assertLength(pages, 1)
- for item in pages:
- self.assertIsInstance(item, pywikibot.User)
-
class PageGeneratorIntersectTestCase(GeneratorIntersectTestCase,
RecentChangesTestCase):
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1361164?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Id599cb55381fd556fadbf83daa6d63a79dac979c
Gerrit-Change-Number: 1361164
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]