gquery
Generator-based query methods which can be used to fetch a limited number of results
GQuery
Collection of queries which fetch and yield results via Generator.
all_users(wiki, groups=[], limit=1)
staticmethod
Lists all users on a wiki. Can filter users by right(s) they have been assigned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
groups |
Union[list[str], str]
|
The group(s) to filter by (e.g. |
[]
|
limit |
Union[int, str]
|
The maximum number of elements to return per iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[str], None, None]
|
Generator[list[str], None, None]: A |
categories_on_page(wiki, title, limit=1)
staticmethod
Fetch the categories used on a page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
title |
str
|
The title to query. |
required |
limit |
Union[int, str]
|
The maxmimum number of elements to fetch each iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[str], None, None]
|
Generator[list[str], None, None]: A |
category_members(wiki, title, ns=[], limit=1)
staticmethod
Fetches the elements in a category.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
title |
str
|
The title of the category to fetch elements from. Must include |
required |
ns |
list[Union[NS, str]]
|
Only return results that are in these namespaces. Optional, set empty list to disable. Defaults to []. |
[]
|
limit |
Union[int, str]
|
The maximum number of elements to return per iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[str], None, None]
|
Generator[list[str], None, None]: A |
contribs(wiki, user, older_first=False, ns=[], limit=1)
staticmethod
Fetches contributions of a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
user |
str
|
The username to query, excluding the |
required |
older_first |
bool
|
Set |
False
|
ns |
list[Union[NS, str]]
|
Only return results that are in these namespaces. Optional, set empty list to disable. Defaults to []. |
[]
|
limit |
Union[int, str]
|
The maximum number of elements to return per iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[Contrib], None, None]
|
Generator[list[Contrib], None, None]: A |
deleted_revisions(wiki, title, limit=1, older_first=False, include_text=False)
staticmethod
Fetches all the deleted revisions of title
. PRECONDITION: You must be logged in and have admin rights in order for this to work.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use. |
required |
title |
str
|
The title to get deleted revisions for. |
required |
limit |
Union[int, str]
|
The maxmimum number of revisions to fetch each iteration. Defaults to 1. |
1
|
older_first |
bool
|
Set to |
False
|
include_text |
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
Generator[list[Revision], None, None]
|
Generator[list[Revision], None, None]: A |
list_duplicate_files(wiki, limit=1)
staticmethod
List files on a wiki which have duplicates by querying the Special page Special:ListDuplicatedFiles
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
limit |
Union[int, str]
|
The maximum number of elements to return per iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[str], None, None]
|
Generator[list[str], None, None]: A |
logs(wiki, title=None, log_type=None, log_action=None, user=None, ns=None, tag=None, start=None, end=None, older_first=False, limit=1)
staticmethod
Fetches Special:Log
entries from a wiki. PRECONDITION: if start
and end
are both set, then start
must occur before end
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
title |
str
|
The title of the page to get logs for, if applicable. Defaults to None. |
None
|
log_type |
str
|
The type of log to fetch (e.g. |
None
|
log_action |
str
|
The type and sub-action of the log to fetch (e.g. |
None
|
user |
str
|
The user associated with the log action, if applicable. Do not include |
None
|
ns |
Union[NS, str]
|
Only return results that are in this namespace. Defaults to None. |
None
|
tag |
str
|
Only return results that are tagged with this tag. Defaults to None. |
None
|
start |
datetime
|
Set to filter out revisions older than this date. If no timezone is specified in the datetime, then UTC is assumed. Defaults to None. |
None
|
end |
datetime
|
Set to filter out revisions newer than this date. If no timezone is specified in the datetime, then UTC is assumed. Defaults to None. |
None
|
older_first |
bool
|
Set to |
False
|
limit |
Union[int, str]
|
The maximum number of elements to return per iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[Log], None, None]
|
Generator[list[Log], None, None]: A |
prefix_index(wiki, ns, prefix, limit=1)
staticmethod
Performs a prefix index query and returns all matching titles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
ns |
Union[NS, str]
|
The namespace to search in. |
required |
prefix |
str
|
Fetches all titles in the specified namespace that start with this str. To return subpages only, append a |
required |
limit |
Union[int, str]
|
The maxmimum number of elements to fetch each iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[str], None, None]
|
Generator[list[str], None, None]: A |
random(wiki, ns=[], limit=1)
staticmethod
Fetches a list of random pages from the wiki.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
ns |
list[Union[NS, str]]
|
Only return results that are in these namespaces. Optional, set empty list to disable. Defaults to []. |
[]
|
limit |
Union[int, str]
|
The maxmimum number of elements to fetch each iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[str], None, None]
|
Generator[list[str], None, None]: A |
revisions(wiki, title, limit=1, older_first=False, start=None, end=None, include_text=False)
staticmethod
Gets the revisions of a page. Fetches newer revisions first by default. PRECONDITION: if start
and end
are both set, then start
must occur before end
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use. |
required |
title |
str
|
The title to get revisions of. |
required |
limit |
Union[int, str]
|
The maxmimum number of revisions to fetch each iteration. Defaults to 1. |
1
|
older_first |
bool
|
Set to |
False
|
start |
datetime
|
Set to filter out revisions older than this date. If no timezone is specified in the datetime, then UTC is assumed. Defaults to None. |
None
|
end |
datetime
|
Set to filter out revisions newer than this date. If no timezone is specified in the datetime, then UTC is assumed. Defaults to None. |
None
|
include_text |
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
Generator[list[Revision], None, None]
|
Generator[list[Revision], None, None]: A |
search(wiki, phrase, ns=[], limit=1)
staticmethod
Perform a search on the wiki.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
phrase |
str
|
The phrase to query with |
required |
ns |
list[Union[NS, str]]
|
Only return results that are in these namespaces. Optional, set empty list to disable. Defaults to []. |
[]
|
limit |
Union[int, str]
|
The maxmimum number of elements to fetch each iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[str], None, None]
|
Generator[list[str], None, None]: A |
stashed_files(wiki, limit=1)
staticmethod
Fetch the user's stashed files. PRECONDITION: You must be logged in for this to work
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
limit |
Union[int, str]
|
The maxmimum number of elements to fetch each iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[tuple[str, int, str]], None, None]
|
Generator[list[tuple[str, int]], None, None]: A |
user_uploads(wiki, user, limit=1)
staticmethod
Gets the uploads of a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
user |
str
|
The username to query, without the |
required |
limit |
Union[int, str]
|
The maxmimum number of elements to fetch each iteration. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
Generator[list[str], None, None]
|
Generator[list[str], None, None]: A |