jenkins-bot has submitted this change and it was merged.
Change subject: Add a family parameter to DataPage.interwiki so users can choose which links they want ......................................................................
Add a family parameter to DataPage.interwiki so users can choose which links they want
Change-Id: If1d0fb8fc902a1509fb964540c518b3d2d765376 --- M wikipedia.py 1 file changed, 10 insertions(+), 4 deletions(-)
Approvals: Ladsgroup: Looks good to me, approved Xqt: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/wikipedia.py b/wikipedia.py index 3d4e924..ccdc5d7 100644 --- a/wikipedia.py +++ b/wikipedia.py @@ -4696,19 +4696,25 @@ def isEmpty(self): return not self.exists()
- def interwiki(self): + def interwiki(self, family='wikipedia'): """Return a list of interwiki links from data repository.
The return value is a list of Page objects for each of the interwiki links.
+ @param family: Which family of links to get + @type family: str """ + if family == 'wikipedia': + suffix = 'wiki' + else: + suffix = family links = self.get()['links'] - self._interwiki = [Page(getSite(code.replace('wiki', + self._interwiki = [Page(getSite(code.replace(suffix, '').replace('_', '-'), - fam='wikipedia'), + fam=family), links[code]) for code in links - if code.endswith('wiki')] + if code.endswith(suffix)] return self._interwiki
def linktitles(self):
pywikibot-commits@lists.wikimedia.org