diff --git a/client.py b/client.py index 0b96315e031c2cf68f95bf4ef14993f5f304728e..efd6a04c545982cd12642838eb67cc23d484e3bc 100644 --- a/client.py +++ b/client.py @@ -238,7 +238,7 @@ class Site(object): self.wait(token) def raw_api(self, action, *args, **kwargs): - """Sends a call to the API.""" + """Sends a call to the API.""" kwargs['action'] = action kwargs['format'] = 'json' data = self._query_string(*args, **kwargs) @@ -251,7 +251,7 @@ class Site(object): raise def raw_index(self, action, *args, **kwargs): - """Sends a call to index.php rather than the API.""" + """Sends a call to index.php rather than the API.""" kwargs['action'] = action kwargs['maxlag'] = self.max_lag data = self._query_string(*args, **kwargs) @@ -293,7 +293,7 @@ class Site(object): # Actions def email(self, user, text, subject, cc = False): - """Sends email to a specified user on the wiki.""" + """Sends email to a specified user on the wiki.""" #TODO: Use api! postdata = {} postdata['wpSubject'] = subject @@ -312,7 +312,7 @@ class Site(object): def login(self, username = None, password = None, cookies = None, domain = None): - """Login to the wiki.""" + """Login to the wiki.""" if self.initialized: self.require(1, 10) if username and password: @@ -354,7 +354,7 @@ class Site(object): def upload(self, file = None, filename = None, description = '', ignore = False, file_size = None, url = None, session_key = None, comment = None): - """Upload a file to the wiki.""" + """Upload a file to the wiki.""" if self.version[:2] < (1, 16): return compatibility.old_upload(self, file = file, filename = filename, description = description, ignore = ignore, @@ -433,7 +433,7 @@ class Site(object): def allpages(self, start = None, prefix = None, namespace = '0', filterredir = 'all', minsize = None, maxsize = None, prtype = None, prlevel = None, limit = None, dir = 'ascending', filterlanglinks = 'all', generator = True): - """Retrieve all pages on the wiki as a generator.""" + """Retrieve all pages on the wiki as a generator.""" self.require(1, 9) pfx = listing.List.get_prefix('ap', generator) @@ -447,7 +447,7 @@ class Site(object): def alllinks(self, start = None, prefix = None, unique = False, prop = 'title', namespace = '0', limit = None, generator = True): - """Retrieve a list of all links on the wiki as a generator.""" + """Retrieve a list of all links on the wiki as a generator.""" self.require(1, 11) pfx = listing.List.get_prefix('al', generator) @@ -457,7 +457,7 @@ class Site(object): return listing.List.get_list(generator)(self, 'alllinks', 'al', limit = limit, return_values = 'title', **kwargs) def allcategories(self, start = None, prefix = None, dir = 'ascending', limit = None, generator = True): - """Retrieve all categories on the wiki as a generator.""" + """Retrieve all categories on the wiki as a generator.""" self.require(1, 12) pfx = listing.List.get_prefix('ac', generator) @@ -465,7 +465,7 @@ class Site(object): return listing.List.get_list(generator)(self, 'allcategories', 'ac', limit = limit, **kwargs) def allusers(self, start = None, prefix = None, group = None, prop = None, limit = None): - """Retrieve all users on the wiki as a generator.""" + """Retrieve all users on the wiki as a generator.""" self.require(1, 11) kwargs = dict(listing.List.generate_kwargs('au', ('from', start), prefix = prefix, @@ -474,19 +474,19 @@ class Site(object): def blocks(self, start = None, end = None, dir = 'older', ids = None, users = None, limit = None, prop = 'id|user|by|timestamp|expiry|reason|flags'): - """Retrieve blocks as a generator. - - Each block is a dictionary containing: - - user: the username or IP address of the user - - id: the ID of the block - - timestamp: when the block was added - - expiry: when the block runs out (infinity for indefinite blocks) - - reason: the reason they are blocked - - allowusertalk: key is present (empty string) if the user is allowed to edit their user talk page - - by: the administrator who blocked the user - - nocreate: key is present (empty string) if the user's ability to create accounts has been disabled. - - """ + """Retrieve blocks as a generator. + + Each block is a dictionary containing: + - user: the username or IP address of the user + - id: the ID of the block + - timestamp: when the block was added + - expiry: when the block runs out (infinity for indefinite blocks) + - reason: the reason they are blocked + - allowusertalk: key is present (empty string) if the user is allowed to edit their user talk page + - by: the administrator who blocked the user + - nocreate: key is present (empty string) if the user's ability to create accounts has been disabled. + + """ self.require(1, 12) # TODO: Fix. Fix what? @@ -504,23 +504,23 @@ class Site(object): return listing.List(self, 'deletedrevs', 'dr', limit = limit, **kwargs) def exturlusage(self, query, prop = None, protocol = 'http', namespace = None, limit = None): - """Retrieves list of pages that link to a particular domain or URL as a generator. + """Retrieves list of pages that link to a particular domain or URL as a generator. - This API call mirrors the Special:LinkSearch function on-wiki. + This API call mirrors the Special:LinkSearch function on-wiki. - Query can be a domain like 'bbc.co.uk'. Wildcards can be used, e.g. '*.bbc.co.uk'. - Alternatively, a query can contain a full domain name and some or all of a URL: - e.g. '*.wikipedia.org/wiki/*' + Query can be a domain like 'bbc.co.uk'. Wildcards can be used, e.g. '*.bbc.co.uk'. + Alternatively, a query can contain a full domain name and some or all of a URL: + e.g. '*.wikipedia.org/wiki/*' - See <https://meta.wikimedia.org/wiki/Help:Linksearch> for details. + See <https://meta.wikimedia.org/wiki/Help:Linksearch> for details. - The generator returns dictionaries containing three keys: - - url: the URL linked to. - - ns: namespace of the wiki page - - pageid: the ID of the wiki page - - title: the page title. - - """ + The generator returns dictionaries containing three keys: + - url: the URL linked to. + - ns: namespace of the wiki page + - pageid: the ID of the wiki page + - title: the page title. + + """ self.require(1, 11) kwargs = dict(listing.List.generate_kwargs('eu', query = query, prop = prop, @@ -537,14 +537,14 @@ class Site(object): # def protectedtitles requires 1.15 def random(self, namespace, limit = 20): - """Retrieves a generator of random page from a particular namespace. - - limit specifies the number of random articles retrieved. - namespace is a namespace identifier integer. - - Generator contains dictionary with namespace, page ID and title. - - """ + """Retrieves a generator of random page from a particular namespace. + + limit specifies the number of random articles retrieved. + namespace is a namespace identifier integer. + + Generator contains dictionary with namespace, page ID and title. + + """ self.require(1, 12) kwargs = dict(listing.List.generate_kwargs('rn', namespace = namespace)) @@ -588,7 +588,7 @@ class Site(object): return listing.List(self, 'watchlist', 'wl', limit = limit, **kwargs) def expandtemplates(self, text, title = None, generatexml = False): - """Takes wikitext (text) and expands templates.""" + """Takes wikitext (text) and expands templates.""" self.require(1, 11) kwargs = {} diff --git a/page.py b/page.py index a32567e82ee7bab578995f8b889960965f7be160..3a20bbb6d5fd44482bf09eda4e86e3fe279b50a7 100644 --- a/page.py +++ b/page.py @@ -94,11 +94,11 @@ class Page(object): return u'' def edit(self, section = None, readonly = False): - """Returns wikitext for a specified section or for the whole page. - - Retrieves the latest edit. - - """ + """Returns wikitext for a specified section or for the whole page. + + Retrieves the latest edit. + + """ if not self.can('read'): raise errors.InsufficientPermission(self) if not self.exists: @@ -116,7 +116,7 @@ class Page(object): return self.text def save(self, text = u'', summary = u'', minor = False, bot = True, **kwargs): - """Save text of page.""" + """Save text of page.""" if not self.site.logged_in and self.site.force_login: # Should we really check for this? raise errors.LoginError(self.site) @@ -167,7 +167,7 @@ class Page(object): if e.code == 'editconflict': raise errors.EditError(self, summary, e.info) elif e.code in ('protectedtitle', 'cantcreate', 'cantcreate-anon', 'noimageredirect-anon', - 'noimageredirect', 'noedit-anon', 'noedit'): + 'noimageredirect', 'noedit-anon', 'noedit'): raise errors.ProtectedPageError(self, e.code, e.info) else: raise @@ -182,15 +182,15 @@ class Page(object): return u'' def move(self, new_title, reason = '', move_talk = True, no_redirect = False): - """Move (rename) page to new_title. + """Move (rename) page to new_title. - If user account is an administrator, specify no_direct as True to not - leave a redirect. - - If user does not have permission to move page, an InsufficientPermission - exception is raised. - - """ + If user account is an administrator, specify no_direct as True to not + leave a redirect. + + If user does not have permission to move page, an InsufficientPermission + exception is raised. + + """ if not self.can('move'): raise errors.InsufficientPermission(self) if not self.site.writeapi: @@ -206,12 +206,12 @@ class Page(object): def delete(self, reason = '', watch = False, unwatch = False, oldimage = False): - """Delete page. - - If user does not have permission to delete page, an InsufficientPermission - exception is raised. - - """ + """Delete page. + + If user does not have permission to delete page, an InsufficientPermission + exception is raised. + + """ if not self.can('delete'): raise errors.InsufficientPermission(self) if not self.site.writeapi: @@ -227,10 +227,10 @@ class Page(object): return result['delete'] def purge(self): - """Purge server-side cache of page. This will re-render templates and other - dynamic content. - - """ + """Purge server-side cache of page. This will re-render templates and other + dynamic content. + + """ self.site.raw_index('purge', title = self.name) # def watch: requires 1.14