Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.
UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.
Rewrite/api.py
Contents |
Proposed interface for api.py module
Error
class Error(pywikibot.Error)
- Throw this exception whenever the API returns an <error> or invalid response
- (Public) Attributes:
-
code: contents of the 'error' 'code' field in the API response- If API returns an unrecognized response, set 'code' to 'Unknown'
-
info: contents of the 'error' 'info' field in the API response -
other: dict containing any other fields found in the API response
-
Request
class Request(object)
- The base class for all API request types
- Constructor:
-
def __init__(self, site=None, format="json", **args)- site: a Site object; if absent, use default Site
- format: do we want to rely on simplejson or XML as the format used internally?
- args:
formatand all other keyword args are placed in a dict to be passed to the wiki
- (Public) Attributes:
- (Public) Methods:
-
def update(self, **args)- Update request's param dict from args
-
def submit(self)- Submit request to the wiki and use simplejson to turn the response into a dict
- Handle routine comm errors at this level
Query
class Query(Request)
- Since at least 75% of all API activity is going to use action=query, it seems to make sense to have a sub-class dedicated to this action that will have some methods that know about particular query types.
- Constructor:
-
def __init__(self, site=None, format="json", **args)- Same as the Request constructor, but add
{'action': 'query'}to the params dict.
- Same as the Request constructor, but add
- (Public) Attributes:
- (Public) Methods: