Revision: 5307 Author: russblau Date: 2008-05-05 18:29:26 +0000 (Mon, 05 May 2008)
Log Message: ----------- Method name changes (get... loads and saves info from wiki; page... iterates information related to a particular page)
Modified Paths: -------------- branches/rewrite/pywikibot/page.py branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/page.py =================================================================== --- branches/rewrite/pywikibot/page.py 2008-05-05 14:32:15 UTC (rev 5306) +++ branches/rewrite/pywikibot/page.py 2008-05-05 18:29:26 UTC (rev 5307) @@ -447,7 +447,7 @@ # to implement those methods in the site interface and then combine # the results for this method, or to implement this method and then # split up the results for the others. - return self.site().getreferences( + return self.site().pagereferences( self, follow_redirects, redirectsOnly, withTemplateInclusion, onlyTemplateInclusion)
@@ -460,11 +460,11 @@ omit redirects; if None, do not filter
""" - return self.site().getbacklinks(self, followRedirects, filterRedirects) + return self.site().pagebacklinks(self, followRedirects, filterRedirects)
def embeddedin(self): """Yield all pages that embed this page as a template.""" - return self.site().getembeddedin(self) + return self.site().page_embeddedin(self)
def canBeEdited(self): """Return bool indicating whether this page can be edited. @@ -574,7 +574,7 @@ @return: a generator that yields Page objects.
""" - return self.site().getlinks(self) + return self.site().pagelinks(self)
def interwiki(self): """Iterate interwiki links in the page text. @@ -582,7 +582,7 @@ @return: a generator that yields Link objects.
""" - return self.site().getinterwiki(self) + return self.site().pageinterwiki(self)
def langlinks(self): """Iterate all interlanguage links on this page. @@ -593,7 +593,7 @@ @return: a generator that yields Link objects.
""" - return self.site().getlanglinks(self) + return self.site().pagelanglinks(self)
def imagelinks(self, followRedirects=None, loose=None): """Iterate ImagePage objects for images displayed on this Page. @@ -609,7 +609,7 @@ if loose is not None: logging.debug( u"Page.imagelinks(loose) option is deprecated.") - return self.site().getimages(self) + return self.site().pageimages(self)
def templates(self): """Iterate Page objects for templates used on this Page. @@ -619,7 +619,7 @@ a normal link.
""" - return self.site().gettemplates(self) + return self.site().pagetemplates(self)
def templatesWithParams(self): """Iterate templates used on this Page. @@ -644,7 +644,7 @@ if nofollow_redirects is not None: logging.debug( u"Page.categories(nofollow_redirects) option is deprecated.") - return self.site().getcategories(self, withSortKey=withSortKey) + return self.site().pagecategories(self, withSortKey=withSortKey)
def extlinks(self): """Iterate all external URLs (not interwiki links) from this page. @@ -652,7 +652,7 @@ @return: a generator that yields unicode objects containing URLs.
""" - return self.site().getextlinks(self) + return self.site().page_extlinks(self)
def getRedirectTarget(self): """Return a Page object for the target this Page redirects to. @@ -664,7 +664,7 @@ if not self.isRedirectPage(): raise pywikibot.IsNotRedirectPage if not isinstance(self._redir, Page): - self.site().getredirtarget(self) + self.site().pageredirtarget(self) return self._redir
def getVersionHistory(self, forceReload=False, reverseOrder=False, @@ -1100,7 +1100,7 @@ recurse = recurse - 1 if not hasattr(self, "_subcats"): self._subcats = [] - for member in self.site().getcategorymembers(self, namespaces=[14]): + for member in self.site().pagecategorymembers(self, namespaces=[14]): subcat = Category(self.site(), member.title()) self._subcats.append(subcat) yield subcat @@ -1127,7 +1127,7 @@ """ namespaces = [x for x in self.site().namespaces().keys() if x>=0 and x!=14] - for member in self.site().getcategorymembers(self, + for member in self.site().pagecategorymembers(self, namespaces=namespaces): yield member if recurse:
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2008-05-05 14:32:15 UTC (rev 5306) +++ branches/rewrite/pywikibot/site.py 2008-05-05 18:29:26 UTC (rev 5307) @@ -540,7 +540,7 @@ self.getpageinfo(page) return bool(page._redir)
- def getredirtarget(self, page): + def pageredirtarget(self, page): """Return Page object for the redirect target of page.""" if not hasattr(page, "_redir"): self.getpageinfo(page) @@ -554,13 +554,13 @@ result = query.submit() if "query" not in result or "redirects" not in result["query"]: raise RuntimeError( - "getredirtarget: No 'redirects' found for page %s." + "pageredirtarget: No 'redirects' found for page %s." % title) redirmap = dict((item['from'], item['to']) for item in result['query']['redirects']) if title not in redirmap: raise RuntimeError( - "getredirtarget: 'redirects' contains no key for page %s." + "pageredirtarget: 'redirects' contains no key for page %s." % title) if "pages" not in result['query']: # no "pages" element indicates a circular redirect @@ -569,7 +569,7 @@ # there should be only one value in 'pages', and it is the target if pagedata['title'] not in redirmap.values(): raise RuntimeError( - "getredirtarget: target page '%s' not found in 'redirects'" + "pageredirtarget: target page '%s' not found in 'redirects'" % pagedata['title']) target = pywikibot.Page(self, pagedata['title'], pagedata['ns']) api.update_page(target, pagedata) @@ -620,7 +620,7 @@
# following group of methods map more-or-less directly to API queries
- def getbacklinks(self, page, followRedirects=False, filterRedirects=None, + def pagebacklinks(self, page, followRedirects=False, filterRedirects=None, namespaces=None): """Iterate all pages that link to the given page.
@@ -646,7 +646,7 @@ blgen.request["gblredirect"] = "" return blgen
- def getembeddedin(self, page, filterRedirects=None, namespaces=None): + def page_embeddedin(self, page, filterRedirects=None, namespaces=None): """Iterate all pages that embedded the given page as a template.
@param page: The Page to get inclusions for. @@ -667,20 +667,20 @@ or "nonredirects" return eigen
- def getreferences(self, page, followRedirects, filterRedirects, + def pagereferences(self, page, followRedirects, filterRedirects, withTemplateInclusion, onlyTemplateInclusion): - """Convenience method combining getbacklinks and getembeddedin.""" + """Convenience method combining pagebacklinks and page_embeddedin.""" if onlyTemplateInclusion: - return self.getembeddedin(page) + return self.page_embeddedin(page) if not withTemplateInclusion: - return self.getbacklinks(page, follow_redirects) + return self.pagebacklinks(page, follow_redirects) import itertools - return itertools.chain(self.getbacklinks( + return itertools.chain(self.pagebacklinks( page, followRedirects, filterRedirects), - self.getembeddedin(page, filterRedirects) + self.page_embeddedin(page, filterRedirects) )
- def getlinks(self, page, namespaces=None): + def pagelinks(self, page, namespaces=None): """Iterate internal wikilinks contained (or transcluded) on page.""" plgen = api.PageGenerator("links") if hasattr(page, "_pageid"): @@ -693,7 +693,7 @@ for ns in namespaces) return plgen
- def getcategories(self, page, withSortKey=False): + def pagecategories(self, page, withSortKey=False): """Iterate categories to which page belongs.""" # Sortkey doesn't work with generator; FIXME or deprecate clgen = api.CategoryPageGenerator("categories") @@ -704,13 +704,13 @@ clgen.request['titles'] = cltitle return clgen
- def getimages(self, page): + def pageimages(self, page): """Iterate images used (not just linked) on the page.""" imtitle = page.title(withSection=False).encode(self.encoding()) imgen = api.ImagePageGenerator("images", titles=imtitle) return imgen
- def gettemplates(self, page, namespaces=None): + def pagetemplates(self, page, namespaces=None): """Iterate templates transcluded (not just linked) on the page.""" tltitle = page.title(withSection=False).encode(self.encoding()) tlgen = api.PageGenerator("templates", titles=tltitle) @@ -719,7 +719,7 @@ for ns in namespaces) return tlgen
- def getcategorymembers(self, category, namespaces=None): + def pagecategorymembers(self, category, namespaces=None): """Iterate members of specified category.
@param category: The Category to iterate. @@ -873,11 +873,11 @@ if latest: page._revid = revision.revid
- def getinterwiki(self, page): + def pageinterwiki(self, page): # TODO raise NotImplementedError
- def getlanglinks(self, page): + def pagelanglinks(self, page): """Iterate all interlanguage links on page, yielding Link objects.""" lltitle = page.title(withSection=False) llquery = api.PropertyGenerator("langlinks", @@ -894,7 +894,7 @@ yield pywikibot.Link(linkdata['*'], source=pywikibot.Site(linkdata['lang']))
- def getextlinks(self, page): + def page_extlinks(self, page): """Iterate all external links on page, yielding URL strings.""" eltitle = page.title(withSection=False) elquery = api.PropertyGenerator("extlinks",
pywikipedia-l@lists.wikimedia.org