jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/756119 )

Change subject: [cleanup] Remove interwiki.PageTree and use SizedKeyCollection 
directly
......................................................................

[cleanup] Remove interwiki.PageTree and use SizedKeyCollection directly

Change-Id: I27b786642c525a12a6f6686d054a99283a2251c1
---
M pywikibot/tools/__init__.py
M scripts/interwiki.py
2 files changed, 7 insertions(+), 37 deletions(-)

Approvals:
  D3r1ck01: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index ec381a2..c201689 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -1,6 +1,6 @@
 """Miscellaneous helper functions (not wiki-dependent)."""
 #
-# (C) Pywikibot team, 2008-2021
+# (C) Pywikibot team, 2008-2022
 #
 # Distributed under the terms of the MIT license.
 #
@@ -238,7 +238,7 @@
     """Structure to hold values where the key is given by the value itself.

     A structure like a defaultdict but the key is given by the value
-    itselfvand cannot be assigned directly. It returns the number of all
+    itself and cannot be assigned directly. It returns the number of all
     items with len() but not the number of keys.

     Samples:
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 1f222fe..47c6d6e 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -545,8 +545,8 @@
             self.summary = value or pywikibot.input(
                 'What summary do you want to use?')
         elif arg == 'lack':
-            self.lacklanguage, sep, minlinks = value.partition(':')
-            self.minlinks = int(minlinks) if minlinks.isdigit() else 1
+            self.lacklanguage, _, minlinks = value.partition(':')
+            self.minlinks = int(minlinks or 1)
         elif arg in ('cleanup', 'confirm', 'force', 'hintnobracket',
                      'hintsareright', 'initialredirect', 'localonly', 'quiet',
                      'repository', 'same', 'select', 'skipauto',
@@ -559,36 +559,6 @@
         return True


-class PageTree(SizedKeyCollection):
-
-    """
-    Structure to manipulate a set of pages.
-
-    Allows filtering efficiently by Site.
-    """
-
-    def __init__(self):
-        """Initializer.
-
-        While using dict values would be faster for the remove() operation,
-        keeping list values is important, because the order in which the pages
-        were found matters: the earlier a page is found, the closer it is to
-        the Subject.origin. Chances are that pages found within 2 interwiki
-        distance from the origin are more related to the original topic
-        than pages found later on, after 3, 4, 5 or more interwiki hops.
-
-        Keeping this order is hence important to display an ordered
-        list of pages to the user when he'll be asked to resolve
-        conflicts.
-
-        :ivar data: dictionary with Site as keys and list of page as values.
-            All pages found within Site are kept in self.data[site].
-
-        :type data: defaultdict(list)
-        """
-        super().__init__('site')
-
-
 class Subject(interwiki_graph.Subject):

     """
@@ -667,16 +637,16 @@
         self.repoPage = None
         # todo is a list of all pages that still need to be analyzed.
         # Mark the origin page as todo.
-        self.todo = PageTree()
+        self.todo = SizedKeyCollection('site')
         if origin:
             self.todo.append(origin)

         # done is a list of all pages that have been analyzed and that
         # are known to belong to this subject.
-        self.done = PageTree()
+        self.done = SizedKeyCollection('site')
         # This is a list of all pages that are currently scheduled for
         # download.
-        self.pending = PageTree()
+        self.pending = SizedKeyCollection('site')
         if self.conf.hintsareright:
             # This is a set of sites that we got hints to
             self.hintedsites = set()

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/756119
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: I27b786642c525a12a6f6686d054a99283a2251c1
Gerrit-Change-Number: 756119
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to