jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] New apply_cosmetic_changes parameter for Page.save() ......................................................................
[IMPROV] New apply_cosmetic_changes parameter for Page.save()
apply_cosmetic_changes may overwrite config.cosmetic_changes setting for a given edit. apply_cosmetic_changes is equivalet to config.cosmetic_changes setting or the setting made by the global option -cosmeticchanges (or -cc). If False, no cosmetic changes where made. If True, cosmetic changes are enabled but may be restricted by other cosmetic changes settings like cosmetic_changes_mylang_only, cosmetic_changes_enable or cosmetic_changes_disable, and by cosmetic_changes_deny_script.
Change-Id: Ife80707deeaebe9eb60572943dba5965bc973fd2 --- M pywikibot/page.py 1 file changed, 10 insertions(+), 6 deletions(-)
Approvals: XZise: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index 389e3c2..73f05ed 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -1007,7 +1007,8 @@
@deprecated_args(comment='summary', sysop=None) def save(self, summary=None, watch=None, minor=True, botflag=None, - force=False, async=False, callback=None, **kwargs): + force=False, async=False, callback=None, + apply_cosmetic_changes=None, **kwargs): """Save the current contents of page's text to the wiki.
@param summary: The edit summary for the modification (optional, but @@ -1039,7 +1040,9 @@ if the page was saved successfully. The callback is intended for use by bots that need to keep track of which saves were successful. - + @param apply_cosmetic_changes: Overwrites the cosmetic_changes + configuration value to this value unless it's None. + @type apply_cosmetic_changes: bool or None """ if not summary: summary = config.default_edit_summary @@ -1053,18 +1056,19 @@ if async: pywikibot.async_request(self._save, summary=summary, minor=minor, watch=watch, botflag=botflag, - async=async, callback=callback, **kwargs) + async=async, callback=callback, + cc=apply_cosmetic_changes, **kwargs) else: self._save(summary=summary, minor=minor, watch=watch, botflag=botflag, async=async, callback=callback, - **kwargs) + cc=apply_cosmetic_changes, **kwargs)
def _save(self, summary, minor, watch, botflag, async, callback, - **kwargs): + cc, **kwargs): """Helper function for save().""" err = None link = self.title(asLink=True) - if config.cosmetic_changes: + if cc or cc is None and config.cosmetic_changes: summary = self._cosmetic_changes_hook(summary) or summary try: done = self.site.editpage(self, summary=summary, minor=minor,
pywikibot-commits@lists.wikimedia.org