Revision: 4988
Author: rotem
Date: 2008-02-09 13:01:56 +0000 (Sat, 09 Feb 2008)
Log Message:
-----------
Page.linkedPages() should not contain image links by default, as they are not normal
links.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-02-09 12:54:10 UTC (rev 4987)
+++ trunk/pywikipedia/wikipedia.py 2008-02-09 13:01:56 UTC (rev 4988)
@@ -1486,11 +1486,10 @@
# representation of an instance can not change after the construction.
return hash(str(self))
- def linkedPages(self):
+ def linkedPages(self, withImageLinks = False):
"""Return a list of Pages that this Page links to.
- Excludes interwiki and category links.
-
+ Excludes interwiki and category links, and also image links by default.
"""
result = []
try:
@@ -1498,7 +1497,6 @@
self.site())
except NoPage:
raise
- #return []
except IsRedirectPage:
raise
except SectionError:
@@ -1521,6 +1519,8 @@
output(u"Page %s contains invalid link to [[%s]]."
% (self.title(), title))
continue
+ if not withImageLinks and page.isImage():
+ continue
if page.sectionFreeTitle():
result.append(page)
return result
@@ -1536,7 +1536,7 @@
"""
results = []
# Find normal images
- for page in self.linkedPages():
+ for page in self.linkedPages(withImageLinks = True):
if page.isImage():
# convert Page object to ImagePage object
imagePage = ImagePage(page.site(), page.title())
Show replies by date