Revision: 8105 Author: alexsh Date: 2010-04-18 12:16:23 +0000 (Sun, 18 Apr 2010)
Log Message: ----------- cleanup old API detect to Site().has_api()
Modified Paths: -------------- trunk/pywikipedia/catlib.py trunk/pywikipedia/upload.py trunk/pywikipedia/watchlist.py
Modified: trunk/pywikipedia/catlib.py =================================================================== --- trunk/pywikipedia/catlib.py 2010-04-16 19:12:44 UTC (rev 8104) +++ trunk/pywikipedia/catlib.py 2010-04-18 12:16:23 UTC (rev 8105) @@ -179,13 +179,7 @@
This should not be used outside of this module. """ - try: - if wikipedia.config.use_api and self.site().versionnumber() >= 11: - api_url = self.site().api_address() - del api_url - else: - raise NotImplementedError # version not support - except NotImplementedError: + if not self.site().has_api() or self.site().versionnumber() < 11: for tag, page in self._oldParseCategory(purge, startFrom): yield tag, page return
Modified: trunk/pywikipedia/upload.py =================================================================== --- trunk/pywikipedia/upload.py 2010-04-16 19:12:44 UTC (rev 8104) +++ trunk/pywikipedia/upload.py 2010-04-18 12:16:23 UTC (rev 8105) @@ -220,13 +220,7 @@ If the upload fails, the user is asked whether to try again or not. If the user chooses not to retry, returns null. """ - try: - if config.use_api and self.targetSite.versionnumber() >= 16: - x = self.targetSite.api_address() - del x - else: - raise NotImplementedError - except NotImplementedError: + if not self.targetSite.has_api() or self.targetSite.versionnumber() < 16: return self._uploadImageOld(debug)
if not hasattr(self,'_contents'):
Modified: trunk/pywikipedia/watchlist.py =================================================================== --- trunk/pywikipedia/watchlist.py 2010-04-16 19:12:44 UTC (rev 8104) +++ trunk/pywikipedia/watchlist.py 2010-04-18 12:16:23 UTC (rev 8105) @@ -59,13 +59,7 @@ return pageName in watchlist
def refresh(site, sysop=False): - try: - if wikipedia.config.use_api and site.versionnumber() >= 10: - x = site.api_address() - del x - else: - raise NotImplementedError - except NotImplementedError: + if not site.has_api() or site.versionnumber() < 10: _refreshOld(site)
# get watchlist special page's URL @@ -79,7 +73,7 @@ 'wlprop': 'title', }
- wikipedia.output(u'Retrieving watchlist for %s' % repr(site)) + wikipedia.output(u'Retrieving watchlist for %s via API.' % repr(site)) #wikipedia.put_throttle() # It actually is a get, but a heavy one. watchlist = [] while True:
pywikipedia-svn@lists.wikimedia.org