Revision: 6671 Author: nicdumz Date: 2009-04-22 17:09:48 +0000 (Wed, 22 Apr 2009)
Log Message: ----------- Adding a Link.fromPage staticmethod
Modified Paths: -------------- branches/rewrite/pywikibot/page.py
Modified: branches/rewrite/pywikibot/page.py =================================================================== --- branches/rewrite/pywikibot/page.py 2009-04-22 16:51:44 UTC (rev 6670) +++ branches/rewrite/pywikibot/page.py 2009-04-22 17:09:48 UTC (rev 6671) @@ -1949,6 +1949,21 @@ def __hash__(self): return hash(self.astext())
+ @staticmethod + def fromPage(page): + """Create a Link from a Page object""" + + link = Link.__new__(Link) + link._site = page.site() + link._section = page.section() + link._namespace = page.namespace() + link._title = page.title(withNamespace=False, + allowInterwiki=False, + withSection=False) + link._anchor = None + + return link + # Utility functions for parsing page titles
def html2unicode(text, ignore = []):