Merlijn van Deen has uploaded a new change for review. https://gerrit.wikimedia.org/r/132805
Change subject: WIP: Add other properties to PreloadingPageGenerator (bug 65161) ...................................................................... WIP: Add other properties to PreloadingPageGenerator (bug 65161) Change-Id: I8f5217236da033daf5140c17b5b8f3dbb7f2d1a5 --- M pywikibot/data/api.py M pywikibot/page.py M pywikibot/pagegenerators.py M pywikibot/site.py 4 files changed, 24 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/05/132805/1 diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 1a85255..3e2cbf3 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1039,6 +1039,18 @@ else: page._langlinks = links + if "links" in pagedict: + pages = [] + for l in pagedict["links"]: + pg = pywikibot.Page(page.site, l['title'], ns=l['ns']) + pages.append(pg) + + if hasattr(page, "_links"): + page._links.extend(pages) + else: + page._links = pages + + if "coordinates" in pagedict: coords = [] for co in pagedict['coordinates']: diff --git a/pywikibot/page.py b/pywikibot/page.py index fe54ef6..e3b0b48 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -983,9 +983,12 @@ @return: a generator that yields Page objects. """ - return self.site.pagelinks(self, namespaces=namespaces, step=step, + if not hasattr(self, '_links'): + self._links = self.site.pagelinks(self, namespaces=namespaces, step=step, total=total, content=content) + return self._links + def interwiki(self, expand=True): """Iterate interwiki links in the page text, excluding language links. diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index d0a64b8..f42a9db 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -205,7 +205,7 @@ if self.site is None: self.site = pywikibot.Site() - def getCombinedGenerator(self): + def getCombinedGenerator(self, preload=False): """Return the combination of all accumulated generators. Only call this after all arguments have been parsed. @@ -237,6 +237,8 @@ if self.articlefilter: return RegexBodyFilterPageGenerator(PreloadingGenerator(dupfiltergen), self.articlefilter) + elif preload: + return PreloadingGenerator(dupfiltergen) else: return dupfiltergen diff --git a/pywikibot/site.py b/pywikibot/site.py index ef20492..dd605e1 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -1353,7 +1353,7 @@ return page._redirtarget def preloadpages(self, pagelist, groupsize=50, templates=False, - langlinks=False): + langlinks=False, links=False): """Return a generator to a list of preloaded pages. Note that [at least in current implementation] pages may be iterated @@ -1377,6 +1377,10 @@ props += '|templates' if langlinks: props += '|langlinks' + if links: + props += '|links' + for page in cache.values(): + page._links = [] rvgen = api.PropertyGenerator(props, site=self) rvgen.set_maximum_items(-1) # suppress use of "rvlimit" parameter if len(pageids) == len(sublist): -- To view, visit https://gerrit.wikimedia.org/r/132805 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8f5217236da033daf5140c17b5b8f3dbb7f2d1a5 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: Merlijn van Deen <valhall...@arctus.nl> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits