XZise has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/230525

Change subject: [FEAT] logevents: Support action on pre 1.17 wikis
......................................................................

[FEAT] logevents: Support action on pre 1.17 wikis

The action is present in the log entries even on wikis before 1.17. So even if
it's only possible to get all log entries with a certain type, it's still
possible to sort out other log entries with the same type but a different
action afterwards.

Change-Id: I19e368b5bad0b2c1cac34453460c7891b64a4fb8
---
M pywikibot/site.py
M tests/logentry_tests.py
2 files changed, 19 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/25/230525/1

diff --git a/pywikibot/site.py b/pywikibot/site.py
index 1a83b36..ad65f8c 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3845,15 +3845,14 @@
 
         legen = self._generator(api.LogEntryListGenerator, type_arg=logtype,
                                 step=step, total=total)
+        action_filter = None
         if logtype is not None:
             if '/' in logtype:
                 if MediaWikiVersion(self.version()) >= 
MediaWikiVersion('1.17'):
                     legen.request['leaction'] = logtype
                 else:
-                    pywikibot.warnig(
-                        "leaction filter for logevents is not implemented on "
-                        "this site.\nUsing letype instead.")
-                    legen.request['letype'] = logtype.split('/')[0]
+                    (legen.request['letype'],
+                     action_filter) = logtype.partition('/')[::2]
             else:
                 legen.request["letype"] = logtype
         if user is not None:
@@ -3868,7 +3867,9 @@
             legen.request["ledir"] = "newer"
         if namespace:
             legen.request["lenamespace"] = namespace
-        return legen
+        for log_entry in legen:
+            if action_filter is None or log_entry.action() == action_filter:
+                yield log_entry
 
     def recentchanges(self, start=None, end=None, reverse=False,
                       namespaces=None, pagelist=None, changetype=None,
diff --git a/tests/logentry_tests.py b/tests/logentry_tests.py
index afc87b3..7802b78 100644
--- a/tests/logentry_tests.py
+++ b/tests/logentry_tests.py
@@ -109,6 +109,19 @@
     __metaclass__ = TestLogentriesMeta
 
 
+class TestLogentrySeparate(TestLogentriesBase):
+
+    """Test general LogEntry properties only on certain entries."""
+
+    def test_action(self, key):
+        """Test that both type and action are respected."""
+        # TODO: Run this test on a wiki before 1.17
+        block_entry = self._get_logentry('block/block')
+        unblock_entry = self._get_logentry('block/unblock')
+        self.assertNotEqual(block_entry.action(), unblock_entry.action())
+        self.assertEqual(block_entry.type(), unblock_entry.type())
+
+
 class TestLogentryParams(TestLogentriesBase):
 
     """Test LogEntry properties specific to their action."""

-- 
To view, visit https://gerrit.wikimedia.org/r/230525
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19e368b5bad0b2c1cac34453460c7891b64a4fb8
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to