mquery
Mass/Bulk query methods and classes designed to fetch as many results as possible in the fewest round trips
MQuery
Collection of queries optimized for performing mass/bulk data retrieval from the API
categories_on_page(wiki, titles)
staticmethod
Fetch the categories used on a page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The titles to query. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |
category_size(wiki, titles)
staticmethod
Queries the Wiki and gets the number of elements categorized in each of the specified categories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use. |
required |
titles |
list[str]
|
The categories to get the size of. Each list element must include the |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict where each key is the category name and each value is an |
duplicate_files(wiki, titles, local_only=True, shared_only=False)
staticmethod
Find duplicates of the specified files if possible.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The list of files to get duplicates of (must start with |
required |
local_only |
bool
|
Set |
True
|
shared_only |
bool
|
Set |
False
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |
exists(wiki, titles)
staticmethod
Queries the Wiki to determine if the specified list of titles exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use. |
required |
titles |
list[str]
|
The titles to query. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |
external_links(wiki, titles)
staticmethod
Fetches external links on a page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The titles to query |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |
file_usage(wiki, titles)
staticmethod
Fetch the titles of all pages displaying the specified list of media files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The files to get file usage of. Each list element must include the |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict such that each key is the title and each value is the list of pages displaying the file. |
global_usage(wiki, titles)
staticmethod
Fetch the global file usage of a media file. Only works with wikis that utilize a shared media respository wiki.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The files to get global usage usage of. Each list element must include the |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict such that each key is the title and each value is the list of tuples (page title, wiki hostname) containing the global usages of the file. |
image_info(wiki, titles)
staticmethod
Fetch image (file) info for media files. This is basically image metadata for each uploaded media file under the specified title. See dwrap.ImageInfo
for details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The files to get image info of. Each list element must include the |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict such that each key is the title and each value is the list of ImageInfo objects associated with the title. |
images_on_page(wiki, titles)
staticmethod
Fetch images/media files used on a page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The titles to query |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict such that each key is the title and each value is the list of images/files that are used on the page. |
links_on_page(wiki, titles, ns=[])
staticmethod
Fetch wiki links on a page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The titles to query |
required |
ns |
Union[list[Union[NS, str]], NS, str]
|
Restrict returned output to titles in these namespaces. Optional, set to empty list to disable. Defaults to []. |
[]
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |
page_text(wiki, titles)
staticmethod
Queries the Wiki for the text of a title.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use. |
required |
titles |
list[str]
|
The titles to query. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |
templates_on_page(wiki, titles)
staticmethod
Fetch templates transcluded on a page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The titles to query |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |
what_links_here(wiki, titles, redirects_only=False, ns=[])
staticmethod
Fetch pages that wiki link (locally) to a page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The titles to query |
required |
redirects_only |
bool
|
Set |
False
|
ns |
Union[list[Union[NS, str]], NS, str]
|
Restrict returned output to titles in these namespaces. Optional, set to empty list to disable. Defaults to []. |
[]
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |
what_transcludes_here(wiki, titles, ns=[])
staticmethod
Fetch pages that translcude a page. If querying for templates, you must include the Template:
prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The titles to query |
required |
ns |
Union[list[Union[NS, str]], NS, str]
|
Restrict returned output to titles in these namespaces. Optional, set to empty list to disable. Defaults to []. |
[]
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |