[Pywikipedia-l] SVN: [5745] trunk/pywikipedia/interwiki.py

nicdumz at svn.wikimedia.org nicdumz at svn.wikimedia.org
Mon Jul 21 11:39:00 UTC 2008


Revision: 5745
Author:   nicdumz
Date:     2008-07-21 11:39:00 +0000 (Mon, 21 Jul 2008)

Log Message:
-----------
* Implementing a TODO
* Minor code cleanups

Modified Paths:
--------------
    trunk/pywikipedia/interwiki.py

Modified: trunk/pywikipedia/interwiki.py
===================================================================
--- trunk/pywikipedia/interwiki.py	2008-07-21 10:45:27 UTC (rev 5744)
+++ trunk/pywikipedia/interwiki.py	2008-07-21 11:39:00 UTC (rev 5745)
@@ -546,8 +546,13 @@
 
     def openSites(self):
         """Return a list of sites for all things we still need to do"""
-        return [page.site() for page in self.todo] # TODO: remove duplicates
+        distinctSites = {}
 
+        for page in self.todo: 
+            site = page.site()
+            distinctSites[site] = site
+        return distinctSites.values()
+
     def willWorkOn(self, site):
         """
         By calling this method, you 'promise' this instance that you will
@@ -557,7 +562,7 @@
         # Bug-check: Isn't there any work still in progress? We can't work on
         # different sites at a time!
         if self.pending != []:
-            raise 'BUG: Can\'t start to work on %s; still working on %s' % (repr(site), self.pending)
+            raise 'BUG: Can\'t start to work on %s; still working on %s' % (site, self.pending)
         # Prepare a list of suitable pages
         for page in self.todo:
             if page.site() == site:
@@ -741,8 +746,6 @@
 
             # Register this fact at the todo-counter.
             counter.minus(page.site())
-            # Assume it's not a redirect
-            isRedirect = False
             # Now check whether any interwiki links should be added to the
             # todo list.
             if page.section() and not page.isRedirectPage():
@@ -759,7 +762,6 @@
                             self.originPage = redirectTargetPage
                             self.pending.append(redirectTargetPage)
                             counter.plus(redirectTargetPage.site)
-                            pass
                         else:
                             # This is a redirect page to the origin. We don't need to
                             # follow the redirection.
@@ -767,7 +769,6 @@
                             for page2 in self.todo:
                                 counter.minus(page2.site())
                             self.todo = []
-                            pass
                     elif not globalvar.followredirect:
                         wikipedia.output(u"NOTE: not following redirects.")
                     else:





More information about the Pywikipedia-l mailing list