jenkins-bot has submitted this change and it was merged.
Change subject: Add Proofread Page preloading functions ......................................................................
Add Proofread Page preloading functions
Implement preload param in API:Properties module "info" to preload text.
Application: on Wikisource, with Extension:Proofread Page, it is possible to preload text from a not existing page in the Page namespace, if the corresponding Index page is present.
If a djvu file is connected to an Index page, text is basically already available, making this script less important.
See also Bug 58963 - prop=info&inprop=preload does not return text and Bug 64853 - port djvutext.py to core
Change-Id: Ic534597fe42c09e8432300a19e77c23a21f21a8e --- M pywikibot/data/api.py M pywikibot/page.py M pywikibot/site.py 3 files changed, 20 insertions(+), 2 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index ea462e2..5ef6cee 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1055,6 +1055,9 @@ if "pageprops" in pagedict: page._pageprops = pagedict['pageprops']
+ if 'preload' in pagedict: + page._preloadedtext = pagedict['preload'] + if "flowinfo" in pagedict: page._flowinfo = pagedict['flowinfo']['flow']
diff --git a/pywikibot/page.py b/pywikibot/page.py index 0c765ce..c54fab5 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -393,6 +393,16 @@ if hasattr(self, "_text"): del self._text
+ def preloadText(self): + """Return the text returned by EditFormPreloadText See API module "info". + + Application: on Wikisource wikis, text can be preloaded even if + a page does not exist, if an Index page is present. + + """ + self.site.loadpageinfo(self, preload=True) + return self._preloadedtext + def properties(self, force=False): """ Returns the various page properties stored for a page diff --git a/pywikibot/site.py b/pywikibot/site.py index 3382686..f9e6223 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -1227,13 +1227,18 @@ except pywikibot.data.api.APIError: # May occur if you are not logged in (no API read permissions). return (0, 0, 0)
- def loadpageinfo(self, page): + def loadpageinfo(self, page, preload=False): """Load page info from api and save in page attributes""" title = page.title(withSection=False) + inprop = 'protection' + if preload: + inprop += '|preload' + query = self._generator(api.PropertyGenerator, type_arg="info", titles=title.encode(self.encoding()), - inprop="protection") + inprop=inprop) + for pageitem in query: if not self.sametitle(pageitem['title'], title): pywikibot.warning(
pywikibot-commits@lists.wikimedia.org