jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
Only run cosmetic changes on wikitext pages

Cosmetic changes have been written for wikitext. Running them on other
types of pages, such as Lua modules or CSS/JS pages, may not be
desirable.

Also simplify the method using dict.get and use parenthesis for
readability.

Change-Id: Ia6f2e6e20504d327cc1475468322e316fe8fd301
---
M pywikibot/page/__init__.py
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 8d7dea7..ff9812f 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -1309,7 +1309,7 @@
cc=None, quiet=False, **kwargs):
"""Helper function for save()."""
link = self.title(as_link=True)
- if cc or cc is None and config.cosmetic_changes:
+ if cc or (cc is None and config.cosmetic_changes):
summary = self._cosmetic_changes_hook(summary)

done = self.site.editpage(self, summary=summary, minor=minor,
@@ -1330,20 +1330,18 @@
else the old edit summary.
@rtype: str
"""
- if self.isTalkPage() or \
+ if self.isTalkPage() or self.content_model != 'wikitext' or \
pywikibot.calledModuleName() in config.cosmetic_changes_deny_script:
return summary
family = self.site.family.name
if config.cosmetic_changes_mylang_only:
- cc = ((family == config.family
- and self.site.lang == config.mylang)
- or family in config.cosmetic_changes_enable
- and self.site.lang in config.cosmetic_changes_enable[family])
+ cc = ((family == config.family and self.site.lang == config.mylang)
+ or self.site.lang in config.cosmetic_changes_enable.get(
+ family, []))
else:
cc = True
- cc = (cc and not
- (family in config.cosmetic_changes_disable
- and self.site.lang in config.cosmetic_changes_disable[family]))
+ cc = cc and self.site.lang not in config.cosmetic_changes_disable.get(
+ family, [])
if not cc:
return summary


To view, visit change 615429. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia6f2e6e20504d327cc1475468322e316fe8fd301
Gerrit-Change-Number: 615429
Gerrit-PatchSet: 4
Gerrit-Owner: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged