def get_api(self): if self.username: api = mwapi.mwapi(self.api_url, self.username, self.password) else: api = mwapi.mwapi(self.api_url) api.set_limit() if self.username: api.login(self.username, self.password, self.domain) return api
def _get_mwapi_for_path(self, path): urls = mwapi.guess_api_urls(path) for url in urls: if url in self.api_cache: return self.api_cache[url] for url in urls: try: api = mwapi.mwapi(url) api.ping() api.set_limit() self.api_cache[url] = api return api except Exception: # traceback.print_exc() continue raise RuntimeError("cannot guess api url for %r" % (path,))