Revision: 6721 Author: nicdumz Date: 2009-04-26 02:51:55 +0000 (Sun, 26 Apr 2009)
Log Message: ----------- Fixing bug #2780256 "Removing of interwiki" :
This indeed came from r6992: - if page in self.done: #XXX: Ugly bugfix - the following line has reportedly thrown "ValueError: list.remove(x): x not in list" - self.done.remove(page) + self.done = PageTree()
The correct replacement is self.done.remove(page), of course. Thanks to Tieump for helping me to track this bug down, and for providing the original patch :)
Modified Paths: -------------- trunk/pywikipedia/interwiki.py
Modified: trunk/pywikipedia/interwiki.py =================================================================== --- trunk/pywikipedia/interwiki.py 2009-04-25 16:21:08 UTC (rev 6720) +++ trunk/pywikipedia/interwiki.py 2009-04-26 02:51:55 UTC (rev 6721) @@ -527,10 +527,17 @@ def add(self, page): site = page.site() if not site in self.tree: - self.tree[site] = [] - self.tree[site].append(page) + self.tree[site] = {} + self.tree[site][page] = True self.size += 1
+ def remove(self, page): + try: + del self.tree[page.site()][page] + self.size -= 1 + except KeyError: + pass + def removeSite(self, site): """ Removes all pages from Site site @@ -951,7 +958,7 @@ (skip, alternativePage) = self.disambigMismatch(page, counter) if skip: wikipedia.output(u"NOTE: ignoring %s and its interwiki links" % page.aslink(True)) - self.done = PageTree() + self.done.remove(page) iw = () if alternativePage: # add the page that was entered by the user @@ -994,7 +1001,7 @@ elif page.isEmpty() and not page.isCategory(): wikipedia.output(u"NOTE: %s is empty; ignoring it and its interwiki links" % page.aslink(True)) # Ignore the interwiki links - self.done = PageTree() + self.done.remove(page) iw = ()
for linkedPage in iw: