jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/705610 )
Change subject: [IMPR] Validate pageTitle parameter of CosmeticChangesToolkit ......................................................................
[IMPR] Validate pageTitle parameter of CosmeticChangesToolkit
Validate pageTitle when initializing the instance
Change-Id: I067a0e3eeeabd15d83d6ff889ddf185b54cca1bf --- M pywikibot/cosmetic_changes.py 1 file changed, 8 insertions(+), 6 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index bb48a3a..9fb3780 100755 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -234,7 +234,7 @@ """Initializer.
:param page: the Page object containing the text to be modified - :param show_diff: show difference after replacements (default: False) + :param show_diff: show difference after replacements :param namespace: DEPRECATED namespace parameter :param pageTitle: DEPRECATED page title parameter :param ignore: ignores if an error occurred and either skips the page @@ -243,13 +243,18 @@ if isinstance(page, pywikibot.BaseSite): self.site = page self.title = pageTitle + + class_name = type(self).__name__ + if self.title is None: + raise ValueError('Page title required for ' + class_name) + try: self.namespace = self.site.namespaces.resolve(namespace).pop(0) except (KeyError, TypeError, IndexError): raise ValueError('{} needs a valid namespace' - .format(self.__class__.__name__)) + .format(class_name)) issue_deprecation_warning( - 'site parameter of CosmeticChangesToolkit', + 'site parameter of ' + class_name, 'a pywikibot.Page object as first parameter', since='20201102') else: @@ -384,9 +389,6 @@ if not self.template: categories = textlib.getCategoryLinks(text, site=self.site)
- if self.title is None: - raise ValueError('Page title required to standardize footer') - if not self.talkpage: subpage = False if self.template:
pywikibot-commits@lists.wikimedia.org