Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for querying the CheckUser log #86

Merged
merged 2 commits into from Jun 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion mwclient/client.py
Expand Up @@ -601,7 +601,6 @@ def allusers(self, start=None, prefix=None, group=None, prop=None, limit=None,
rights=rights,
witheditsonly=witheditsonly,
activeusers=activeusers))
print kwargs
return listing.List(self, 'allusers', 'au', limit=limit, **kwargs)

def blocks(self, start=None, end=None, dir='older', ids=None, users=None, limit=None,
Expand Down Expand Up @@ -663,6 +662,12 @@ 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
9 changes: 9 additions & 0 deletions mwclient/listing.py
Expand Up @@ -107,6 +107,15 @@ def get_list(generator=False):
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