http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11024
Revision: 11024 Author: drtrigon Date: 2013-02-02 12:34:01 +0000 (Sat, 02 Feb 2013) Log Message: ----------- new feature; enable revid in permalink
Modified Paths: -------------- branches/rewrite/pywikibot/page.py branches/rewrite/scripts/category_redirect.py
Modified: branches/rewrite/pywikibot/page.py =================================================================== --- branches/rewrite/pywikibot/page.py 2013-02-02 11:29:35 UTC (rev 11023) +++ branches/rewrite/pywikibot/page.py 2013-02-02 12:34:01 UTC (rev 11024) @@ -324,14 +324,18 @@ # TODO: what about redirects, errors? return self._revisions[oldid].text
- def permalink(self): - """Return the permalink URL for current revision of this page.""" + def permalink(self, oldid=None): + """Return the permalink URL of an old revision of this page. + + @param oldid: The revid of the revision desired. + + """ return "%s://%s/%sindex.php?title=%s&oldid=%s" \ % (self.site.protocol(), self.site.hostname(), self.site.scriptpath(), self.title(asUrl=True), - self.latestRevision()) + (oldid if oldid is not None else self.latestRevision()))
def latestRevision(self): """Return the current revision id for this page."""
Modified: branches/rewrite/scripts/category_redirect.py =================================================================== --- branches/rewrite/scripts/category_redirect.py 2013-02-02 11:29:35 UTC (rev 11023) +++ branches/rewrite/scripts/category_redirect.py 2013-02-02 12:34:01 UTC (rev 11024) @@ -220,12 +220,8 @@ rotate_revid = history[-1][0] # append permalink log_text = log_text + ( - "\n\n'''[%s://%s%s/index.php?title=%s&oldid=%s Older logs]'''" - % (self.site.protocol(), - self.site.hostname(), - self.site.scriptpath(), - self.log_page.title(asUrl=True), - rotate_revid)) + "\n\n'''[%s Older logs]'''" + % self.log_page.permalink(oldid=rotate_revid)) return log_text
def run(self):
pywikipedia-svn@lists.wikimedia.org