def recently_changed_pages(timestamp): changes = site.recentchanges(start=timestamp, namespace=0, toponly=1, type='edit|new', dir='newer', show='!minor|!redirect|!anon|!bot') for page in changes: title = page.get('title') if title: doc = db.get(title) doc_revid = doc.get('parse', {}).get('revid') if doc else None revid = page.get('revid') if doc_revid == revid: continue yield title
def redirects_to(site, from_title): """ Same as mwclient.page.Page.redirects_to except it returns page and fragment in a named tuple instead of just target page """ info = site.api('query', prop='pageprops', titles=from_title, redirects='')['query'] if 'redirects' in info: for page in info['redirects']: if page['from'] == from_title: return Redirect(page=mwclient.page.Page(site, page['to']), fragment=page.get('tofragment', u'')) return None else: return None
def redirects_to(site, from_title): """ Same as mwclient.page.Page.redirects_to except it returns page and fragment in a named tuple instead of just target page """ info = site.api('query', prop='pageprops', titles=from_title, redirects='')['query'] if 'redirects' in info: for page in info['redirects']: if page['from'] == from_title: return Redirect( page=mwclient.page.Page(site, page['to']), fragment=page.get('tofragment', u'') ) return None else: return None
def set_iter(self, data): for page in six.itervalues(data['query']['pages']): if page['title'] == self.page.name: self._iter = iter(page.get(self.list_name, ())) return raise StopIteration