jenkins-bot has submitted this change and it was merged.
Change subject: Fix and rewrite PageGenerator's query string ......................................................................
Fix and rewrite PageGenerator's query string
The old code has a flaw when, for example, iiprop is in kwargs. Instead of "xxx|timestamp|...", the query string will be "xxxtimestamp|..." which is wrong. This patch fixes the problem and remove redundancy of the code.
Change-Id: I7d496a612d32c70ccb53d2cdcf95cc036944d808 --- M pywikibot/data/api.py 1 file changed, 11 insertions(+), 18 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index a574935..45c5d04 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -769,27 +769,20 @@ version of each Page (default False)
""" + def appendParams(params, key, value): + if key in params: + params[key] += '|' + value + else: + params[key] = value # get some basic information about every page generated - if 'prop' in kwargs: - kwargs['prop'] += "|info|imageinfo|categoryinfo" - else: - kwargs['prop'] = 'info|imageinfo|categoryinfo' + appendParams(kwargs, 'prop', 'info|imageinfo|categoryinfo') if g_content: # retrieve the current revision - kwargs['prop'] += "|revisions" - if "rvprop" in kwargs: - kwargs["rvprop"] += "ids|timestamp|flags|comment|user|content" - else: - kwargs["rvprop"] = "ids|timestamp|flags|comment|user|content" - if "inprop" in kwargs: - if "protection" not in kwargs["inprop"]: - kwargs["inprop"] += "|protection" - else: - kwargs['inprop'] = 'protection' - if "iiprop" in kwargs: - kwargs["iiprop"] += 'timestamp|user|comment|url|size|sha1|metadata' - else: - kwargs['iiprop'] = 'timestamp|user|comment|url|size|sha1|metadata' + appendParams(kwargs, 'prop', 'revisions') + appendParams(kwargs, 'rvprop', 'ids|timestamp|flags|comment|user|content') + if not ('inprop' in kwargs and 'protection' in kwargs['inprop']): + appendParams(kwargs, 'inprop', 'protection') + appendParams(kwargs, 'iiprop', 'timestamp|user|comment|url|size|sha1|metadata') QueryGenerator.__init__(self, generator=generator, **kwargs) self.resultkey = "pages" # element to look for in result
pywikibot-commits@lists.wikimedia.org