Revision: 8198 Author: russblau Date: 2010-05-19 19:10:12 +0000 (Wed, 19 May 2010)
Log Message: ----------- Fix bug #3002650: .nice_get_address() used but not implemented
Modified Paths: -------------- branches/rewrite/pywikibot/family.py branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/family.py =================================================================== --- branches/rewrite/pywikibot/family.py 2010-05-19 18:51:33 UTC (rev 8197) +++ branches/rewrite/pywikibot/family.py 2010-05-19 19:10:12 UTC (rev 8198) @@ -730,6 +730,9 @@ def nicepath(self, code): return '/wiki/'
+ def nice_get_address(self, code, title): + return '%s%s' % (self.nicepath(code), title) + def dbName(self, code): # returns the name of the MySQL database return '%s%s' % (code, self.name)
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2010-05-19 18:51:33 UTC (rev 8197) +++ branches/rewrite/pywikibot/site.py 2010-05-19 19:10:12 UTC (rev 8198) @@ -410,6 +410,10 @@
return pywikibot.Site(code=code, fam=self.family, user=self.user())
+ def nice_get_address(self, title): + """Return shorter URL path to retrieve page titled 'title'.""" + return self.family.nice_get_address(self.lang, title) + # deprecated methods for backwards-compatibility
@deprecated("family attribute") @@ -474,8 +478,6 @@ raise NotImplementedError def get_address(self, s): raise NotImplementedError - def nice_get_address(self, s): - raise NotImplementedError def edit_address(self, s): raise NotImplementedError def purge_address(self, s): @@ -978,6 +980,11 @@
lang = property(fget=language, doc=language.__doc__)
+ def nice_get_address(self, title): + """Return shorter URL path to retrieve page titled 'title'.""" + # 'title' is expected to be URL-encoded already + return self.siteinfo["articlepath"].replace("$1", title) + def namespaces(self): """Return dict of valid namespaces on this wiki."""
pywikipedia-svn@lists.wikimedia.org