oquery
Classes and constants for making miscellaneous and other one-off queries
OQuery
Collection of miscellaneous and one-off query action methods
fetch_namespaces(wiki)
staticmethod
Fetches namespace data from the Wiki and returns it as an NSManager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
Raises:
Type | Description |
---|---|
OSError
|
If there was a network error or bad reply from the server. |
Returns:
Name | Type | Description |
---|---|---|
NSManager |
NSManager
|
An NSManager containing namespace data. |
fetch_token(wiki, login_token=False)
staticmethod
Fetch a csrf or login token from the server. By default, this method will retrieve a csrf token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
login_token |
bool
|
Set |
False
|
Raises:
Type | Description |
---|---|
Exception
|
if there was a server error or the token couldn't be retrieved. |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The token as a str. |
list_user_rights(wiki, users)
staticmethod
Lists user rights for the specified users.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use. |
required |
users |
list[str]
|
The list of users to get rights for. Usernames must be well formed (e.g. no wacky capitalization), and should not contain the |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict such that each key is the username (without the |
normalize_titles(wiki, titles)
staticmethod
Normalizes titles to match their canonical versions. Usually this means fixing capitalization or replacing underscores with spaces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use. |
required |
titles |
list[str]
|
The titles to normalize. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A |
resolve_redirects(wiki, titles)
staticmethod
Fetch the targets of redirect pages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
titles |
list[str]
|
The list of titles to query |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict where each key is the title and the value is the redirect target. If the key was not a redirect, then the value will be identical to the key. |
uploadable_filetypes(wiki)
staticmethod
Queries the Wiki for all acceptable file types which may be uploaded to this Wiki. PRECONDITION: the target Wiki permits file uploads.
Returns:
Name | Type | Description |
---|---|---|
set |
set[str]
|
A set containing all acceptable file types as their extensions ("." prefix is included). None if something went wrong. |
whoami(wiki)
staticmethod
Get this Wiki's username from the server. If not logged in, then this will return your external IP address.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wiki |
Wiki
|
The Wiki object to use |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
If logged in, this Wiki's username, otherwise the external IP address of your device. None if something went wrong. |