Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/79554
Change subject: Add an ItemPage.iterlinks function to yield sitelinks
......................................................................
Add an ItemPage.iterlinks function to yield sitelinks
Change-Id: I43ab820a5d97a22619dc5753d98bdd4ceec277f7
---
M pywikibot/page.py
1 file changed, 16 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/54/79554/1
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 72540eb..31b243e 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2540,6 +2540,22 @@
'claims': self.claims
}
+ def iterlinks(self, family=None):
+ """
+ Iterates through all the sitelinks
+ @param family: string which represents what family of links to iterate
+ @return: iterator of pywikibot.Page objects
+ """
+ if not hasattr(self, 'sitelinks'):
+ self.get()
+
+ if family == 'wikipedia':
+ family = 'wiki'
+ for dbname in self.sitelinks:
+ if family and not dbname.endswith(family):
+ continue
+ yield Page(pywikibot.site.APISite.fromDBName(dbname),
self.sitelinks[dbname])
+
def getSitelink(self, site, force=False):
"""
Returns the title (unicode string) for the specific site
--
To view, visit https://gerrit.wikimedia.org/r/79554
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I43ab820a5d97a22619dc5753d98bdd4ceec277f7
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits