http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10674
Revision: 10674 Author: xqt Date: 2012-11-08 09:05:21 +0000 (Thu, 08 Nov 2012) Log Message: ----------- new methods for repositories; use family methods by __getattr__ call
Modified Paths: -------------- branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2012-11-08 07:57:03 UTC (rev 10673) +++ branches/rewrite/pywikibot/site.py 2012-11-08 09:05:21 UTC (rev 10674) @@ -1046,21 +1046,29 @@ def image_repository(self): """Return Site object for image repository e.g. commons."""
- code, fam = self.family.shared_image_repository(self.code) + code, fam = self.shared_image_repository() if bool(code or fam): - return pywikibot.Site(code, fam, self.user()) + return pywikibot.Site(code, fam, self.username()) else: return None
def data_repository(self): """Return Site object for data repository e.g. wikidata."""
- code, fam = self.family.shared_data_repository(self.code) + code, fam = self.shared_data_repository(write) if bool(code or fam): - return pywikibot.Site(code, fam, self.user()) + return pywikibot.Site(code, fam, self.username()) else: return None
+ def is_image_repository(self): + """Return True if Site object is the image repository.""" + return self is self.image_repository() + + def is_data_repository(self): + """Return True if Site object is the data repository.""" + return self is self.data_repository() + def nice_get_address(self, title): """Return shorter URL path to retrieve page titled 'title'.""" # 'title' is expected to be URL-encoded already