Skip to content

Commit

Permalink
Add support for querying the CheckUser log.
Browse files Browse the repository at this point in the history
  • Loading branch information
lfaraone committed Jun 14, 2015
1 parent 3a1fc86 commit 0a37e88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mwclient/client.py
Expand Up @@ -662,6 +662,13 @@ def logevents(self, type=None, prop=None, start=None, end=None,
end=end, dir=dir, user=user, title=title, action=action))
return listing.List(self, 'logevents', 'le', limit=limit, **kwargs)

def checkuserlog(self, user=None, target=None, limit=10, dir='older', start=None, end=None):

kwargs = dict(listing.List.generate_kwargs('cul', target=target, start=start,
end=end, dir=dir, user=user))
return listing.NestedList('entries', self, 'checkuserlog', 'cul', limit=limit, **kwargs)


# def protectedtitles requires 1.15
def random(self, namespace, limit=20):
"""Retrieves a generator of random page from a particular namespace.
Expand Down
7 changes: 7 additions & 0 deletions mwclient/listing.py
Expand Up @@ -106,7 +106,14 @@ def get_list(generator=False):
else:
return List

class NestedList(List):
def __init__(self, nested_param, *args, **kwargs):
List.__init__(self, *args, **kwargs)
self.nested_param = nested_param


def set_iter(self, data):
self._iter = iter(data['query'][self.result_member][self.nested_param])
class GeneratorList(List):

def __init__(self, site, list_name, prefix, *args, **kwargs):
Expand Down

0 comments on commit 0a37e88

Please sign in to comment.