http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9005
Revision: 9005 Author: xqt Date: 2011-02-24 12:47:23 +0000 (Thu, 24 Feb 2011) Log Message: ----------- enable Page.urlname() without namespace
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2011-02-24 11:01:05 UTC (rev 9004) +++ trunk/pywikipedia/wikipedia.py 2011-02-24 12:47:23 UTC (rev 9005) @@ -541,9 +541,12 @@ else: return title
- def urlname(self): + def urlname(self, withNamespace=True): """Return the Page title encoded for use in an URL.""" - title = self.title(underscore = True) + if withNamespace: + title = self.title(underscore=True) + else: + title = self.titleWithoutNamespace(underscore=True) encodedTitle = title.encode(self.site().encoding()) return urllib.quote(encodedTitle)