ws.autopage module¶
- class ws.autopage.AutoPage(api, title=None, fetch_titles=None)¶
Bases:
objectA quick interface for maintaining automatic content on wiki pages.
- Parameters
api – an
ws.client.api.APIinstancetitle (str) – the title of the initial page to use
fetch_titles (set) – A set of titles whose content should be fetched from the wiki. These are the pages that will be updated later on; the page title should be switched by the
set_title()method. IfNoneis supplied,fetch_titlesdefaults to[title].
- fetch_pages(titles)¶
Fetch content of given pages from the API. As an optimization, as many pages as possible should be fetched in a single query.
- Parameters
titles (set) – set of page titles
- set_title(title)¶
Set current title to
titleand parse its content. Unsaved changes to previous page will be lost. The content of the page should have been fetched byfetch_pages(), otherwiseValueErrorwill be raised.- Parameters
title (str) – the page title
- get_tag_by_id(tag, id)¶
Finds a tag in the wikicode of the current page with given ID.
- Parameters
- Returns
A
mwparserfromhell.nodes.tag.Taginstance if found, otherwiseNone.
- is_old_enough(min_interval=datetime.timedelta(0), strip_time=False)¶
Checks if the page on the wiki is old enough to be updated again.
- Parameters
min_interval (datetime.timedelta) – Minimum desired interval between two consecutive updates.
strip_time (bool) – If
True, time is stripped from the UTC timestamps and only the dates are compared.
- Returns
Trueif the wiki page is older thanmin_interval.
- save(edit_summary, interactive=False, **kwargs)¶
Saves the updated wikicode of the page to the wiki.
- Parameters
edit_summary (str) – Summary of the change.
interactive (bool) – If
True, callsws.interactive.edit_interactive()to ask the user before making the change; otherwise callsAPI.editdirectly.kwargs – Additional keyword arguments passed to the API query.