def usercontributions(self, user, start = None, end = None, dir = 'older', namespace = None, prop = None, show = None, limit = None): self.require(1, 9) kwargs = dict(listing.List.generate_kwargs('uc', user = user, start = start, end = end, dir = dir, namespace = namespace, prop = prop, show = show)) return listing.List(self, 'usercontribs', 'uc', limit = limit, **kwargs)
def blocks(self, start = None, end = None, dir = 'older', ids = None, users = None, limit = None, prop = 'id|user|by|timestamp|expiry|reason|flags'): self.require(1, 12) # TODO: Fix. Fix what? kwargs = dict(listing.List.generate_kwargs('bk', start = start, end = end, dir = dir, users = users, prop = prop)) return listing.List(self, 'blocks', 'bk', limit = limit, **kwargs)
def recentchanges(self, start = None, end = None, dir = 'older', namespace = None, prop = None, show = None, limit = None, type = None): self.require(1, 9) kwargs = dict(listing.List.generate_kwargs('rc', start = start, end = end, dir = dir, namespace = namespace, prop = prop, show = show, type = type)) return listing.List(self, 'recentchanges', 'rc', limit = limit, **kwargs)
def logevents(self, type = None, prop = None, start = None, end = None, dir = 'older', user = None, title = None, limit = None): self.require(1, 9) kwargs = dict(listing.List.generate_kwargs('le', prop = prop, type = type, start = start, end = end, dir = dir, user = user, title = title)) return listing.List(self, 'logevents', 'le', limit = limit, **kwargs)
def exturlusage(self, query, prop=None, protocol='http', namespace=None, limit=None): """Retrieves list of pages that link to a particular domain or URL as a generator. This API call mirrors the Special:LinkSearch function on-wiki. Query can be a domain like 'bbc.co.uk'. Wildcards can be used, e.g. '*.bbc.co.uk'. Alternatively, a query can contain a full domain name and some or all of a URL: e.g. '*.wikipedia.org/wiki/*' See <https://meta.wikimedia.org/wiki/Help:Linksearch> for details. The generator returns dictionaries containing three keys: - url: the URL linked to. - ns: namespace of the wiki page - pageid: the ID of the wiki page - title: the page title. """ kwargs = dict( listing.List.generate_kwargs('eu', query=query, prop=prop, protocol=protocol, namespace=namespace)) return listing.List(self, 'exturlusage', 'eu', limit=limit, **kwargs)
def users(self, users, prop='blockinfo|groups|editcount'): return listing.List(self, 'users', 'us', ususers='|'.join(users), usprop=prop)
def blocks(self, start=None, end=None, dir='older', ids=None, users=None, limit=None, prop='id|user|by|timestamp|expiry|reason|flags'): """Retrieve blocks as a generator. Each block is a dictionary containing: - user: the username or IP address of the user - id: the ID of the block - timestamp: when the block was added - expiry: when the block runs out (infinity for indefinite blocks) - reason: the reason they are blocked - allowusertalk: key is present (empty string) if the user is allowed to edit their user talk page - by: the administrator who blocked the user - nocreate: key is present (empty string) if the user's ability to create accounts has been disabled. """ # TODO: Fix. Fix what? kwargs = dict( listing.List.generate_kwargs('bk', start=start, end=end, dir=dir, users=users, prop=prop)) return listing.List(self, 'blocks', 'bk', limit=limit, **kwargs)
def deletedrevisions(self, start=None, end=None, dir='older', namespace=None, limit=None, prop='user|comment'): # TODO: Fix kwargs = dict(listing.List.generate_kwargs('dr', start=start, end=end, dir=dir, namespace=namespace, prop=prop)) return listing.List(self, 'deletedrevs', 'dr', limit=limit, **kwargs)
def watchlist(self, allrev = False, start = None, end = None, namespace = None, dir = 'older', prop = None, show = None, limit = None): self.require(1, 9) kwargs = dict(listing.List.generate_kwargs('wl', start = start, end = end, namespace = namespace, dir = dir, prop = prop, show = show)) if allrev: kwargs['wlallrev'] = '1' return listing.List(self, 'watchlist', 'wl', limit = limit, **kwargs)
def allusers(self, start=None, prefix=None, group=None, prop=None, limit=None, witheditsonly=False, activeusers=False, rights=None): """Retrieve all users on the wiki as a generator.""" kwargs = dict(listing.List.generate_kwargs('au', ('from', start), prefix=prefix, group=group, prop=prop, rights=rights, witheditsonly=witheditsonly, activeusers=activeusers)) return listing.List(self, 'allusers', 'au', limit=limit, **kwargs)
def random(self, namespace, limit=20): """Retrieves a generator of random page from a particular namespace. limit specifies the number of random articles retrieved. namespace is a namespace identifier integer. Generator contains dictionary with namespace, page ID and title. """ kwargs = dict(listing.List.generate_kwargs('rn', namespace=namespace)) return listing.List(self, 'random', 'rn', limit=limit, **kwargs)
def allusers(self, start=None, prefix=None, group=None, prop=None, limit=None): self.require(1, 11) kwargs = dict( listing.List.generate_kwargs('au', ('from', start), prefix=prefix, group=group, prop=prop)) return listing.List(self, 'allusers', 'au', limit=limit, **kwargs)
def search(self, search, namespace='0', what='title', redirects=False, limit=None): kwargs = dict( listing.List.generate_kwargs('sr', search=search, namespace=namespace, what=what)) if redirects: kwargs['srredirects'] = '1' return listing.List(self, 'search', 'sr', limit=limit, **kwargs)
def exturlusage(self, query, prop=None, protocol='http', namespace=None, limit=None): self.require(1, 11) kwargs = dict( listing.List.generate_kwargs('eu', query=query, prop=prop, protocol=protocol, namespace=namespace)) return listing.List(self, 'exturlusage', 'eu', limit=limit, **kwargs)
def random(self, namespace, limit = 20): self.require(1, 12) kwargs = dict(listing.List.generate_kwargs('rn', namespace = namespace)) return listing.List(self, 'random', 'rn', limit = limit, **kwargs)