specialbots — Special Reusable Bots#
Module containing special bots reusable by scripts.
- class specialbots.BaseUnlinkBot(**kwargs)[source]#
A basic bot unlinking a given link from the current page.
Redirect all parameters and add namespace as an available option.
- use_redirects: Optional[bool] = False#
Attribute to determine whether to use redirect pages. Set it to True to use redirects only, set it to False to skip redirects. If None both are processed. For example to create a RedirectBot you may define:
class MyRedirectBot(ExistingPageBot): '''Bot who only works on existing redirects.''' use_redirects = True
New in version 7.2.
- class specialbots.InteractiveUnlink(bot)[source]#
An implementation which just allows unlinking.
Create default settings.
- class specialbots.UploadRobot(url, *, url_encoding=None, description='', use_filename=None, keep_filename=False, verify_description=True, ignore_warning=False, target_site=None, aborts=None, chunk_size=0, asynchronous=False, summary=None, filename_prefix=None, force_if_shared=False, **kwargs)[source]#
Changed in version 6.2: asynchronous upload is used if asynchronous parameter is set
Changed in version 6.4: force_if_shared parameter was added
url (Union[List[str], str]) – path to url or local file, or list of urls or paths to local files.
description (str) – Description of file for its page. If multiple files are uploading the same description is used for every file.
use_filename – Specify title of the file’s page. If multiple files are uploading it asks to change the name for second, third, etc. files, otherwise the last file will overwrite the other.
keep_filename (bool) – Set to True to keep original names of urls and files, otherwise it will ask to enter a name for each file.
summary (Optional[str]) – Summary of the upload
verify_description (bool) – Set to True to proofread the description.
ignore_warning (Union[bool, list]) – Set this to True to upload even if another file would be overwritten or another mistake would be risked. Set it to an array of warning codes to selectively ignore specific warnings.
target_site (object) – Set the site to upload to. If target site is not given it’s taken from user config file (user_config.py).
aborts (Optional[Union[bool, list]]) – List of the warning types to abort upload on. Set to True to abort on any warning.
chunk_size (int) – Upload the file in chunks (more overhead, but restartable) specified in bytes. If no value is specified the file will be uploaded as whole.
asynchronous (bool) – Make potentially large file operations asynchronous on the server side when possible.
filename_prefix (Optional[str]) – Specify prefix for the title of every file’s page.
force_if_shared (bool) – Upload the file even if it’s currently shared to the target site (e.g. when moving from Commons to another wiki)
- Keyword Arguments:
always – Disables any input, requires that either ignore_warning or aborts are set to True and that the description is also set. It overwrites verify_description to False and keep_filename to True.
Determine if the warning message should be ignored.
warn_code (str) – The warning message
Return name of temp file in which remote file is saved.
file_url (str) –
Upload the image at file_url to the target wiki.
Return the filename that was used to upload the image. If the upload fails, ask the user whether to try again or not. If the user chooses not to retry, return None.
Changed in version 7.0: If ‘copyuploadbaddomain’ API error occurred in first step, download the file and upload it afterwards