jenkins-bot has submitted this change and it was merged.
Change subject: Use Page.touch() for touch script
......................................................................
Use Page.touch() for touch script
Page.touch() does not add pages to user's watchlist
Also remove -redir parameter which is no longer supported
bug: T69528
Change-Id: I771bd536cd3c9dd7383d8ecf24e72f630945e58c
---
M scripts/touch.py
1 file changed, 4 insertions(+), 14 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/touch.py b/scripts/touch.py
index 359d320..286d091 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -12,8 +12,6 @@
-purge Do not touch but purge the page
--redir specifies that the bot should work on redirect pages;
- otherwise, they will be skipped. Cannot be used with -purge.
"""
#
# (C) Pywikibot team, 2009-2015
@@ -37,26 +35,15 @@
def __init__(self, generator, **kwargs):
"""Initialize a TouchBot instance with the options and generator."""
- self.availableOptions.update({
- 'redir': False, # include redirect pages
- })
-
super(TouchBot, self).__init__(generator=generator, **kwargs)
def treat(self, page):
"""Touch the given page."""
try:
- # get the page, and save it using the unmodified text.
- # whether or not getting a redirect throws an exception
- # depends on the variable self.touch_redirects.
- page.get(get_redirect=self.getOption('redir'))
- page.save("Pywikibot touch script")
+ page.touch()
except pywikibot.NoPage:
pywikibot.error(u"Page %s does not exist."
% page.title(asLink=True))
- except pywikibot.IsRedirectPage:
- pywikibot.warning(u"Page %s is a redirect; skipping."
- % page.title(asLink=True))
except pywikibot.LockedPage:
pywikibot.error(u"Page %s is locked."
% page.title(asLink=True))
@@ -96,6 +83,9 @@
for arg in local_args:
if arg == '-purge':
bot_class = PurgeBot
+ elif arg == '-redir':
+ pywikibot.output(u'-redirect option is deprecated, '
+ 'do not use it anymore.')
elif not genFactory.handleArg(arg) and arg.startswith("-"):
options[arg[1:].lower()] = True
--
To view, visit https://gerrit.wikimedia.org/r/210913
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I771bd536cd3c9dd7383d8ecf24e72f630945e58c
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: New Page.touch() method for touch edit of page without any changes
......................................................................
New Page.touch() method for touch edit of page without any changes
Also test that Page.touch() does not do a real edit.
Change-Id: I8f9cd8d9848e333633615c09c9a1b1015e4e16c3
---
M pywikibot/page.py
M tests/edit_failure_tests.py
2 files changed, 29 insertions(+), 0 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 73f05ed..587e991 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1178,6 +1178,26 @@
"""
return self.site.purgepages([self], **kwargs)
+ def touch(self, callback=None, **kwargs):
+ """Make a touch edit for this page.
+
+ See save() method docs for all parameters.
+ The following parameters will be overridden by this method:
+ summary, watch, minor, botflag, force, async
+
+ minor and botflag parameters are set to False which prevents hiding
+ the edit when it becomes a real edit due to a bug.
+ """
+ if self.exists():
+ # ensure always get the page text and not to change it.
+ del self.text
+ self.save(summary='Pywikibot touch edit', watch='nochange',
+ minor=False, botflag=False, force=True, async=False,
+ callback=callback, apply_cosmetic_changes=False,
+ **kwargs)
+ else:
+ raise pywikibot.NoPage(self)
+
def linkedPages(self, namespaces=None, step=None, total=None,
content=False):
"""Iterate Pages that this Page links to.
diff --git a/tests/edit_failure_tests.py b/tests/edit_failure_tests.py
index 01b163d..c54aca4 100644
--- a/tests/edit_failure_tests.py
+++ b/tests/edit_failure_tests.py
@@ -55,6 +55,15 @@
page = pywikibot.Page(self.site, 'User:John Vandenberg/nobots')
self.assertRaisesRegex(OtherPageSaveError, 'nobots', page.save)
+ def test_touch(self):
+ """Test that Page.touch() does not do a real edit."""
+ page = pywikibot.Page(self.site, 'User:Xqt/sandbox')
+ old_text = page.text
+ page.text += '\n*Add a new line to page'
+ page.touch()
+ new_text = page.get(force=True)
+ self.assertEqual(old_text, new_text)
+
class TestActionFailure(TestCase):
--
To view, visit https://gerrit.wikimedia.org/r/144717
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8f9cd8d9848e333633615c09c9a1b1015e4e16c3
Gerrit-PatchSet: 17
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2230
Status: Errored
Duration: 50 minutes and 3 seconds
Commit: 5275065 (master)
Author: xqt
Message: [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
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/8693e21f9532...5275065c…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/62682157
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2229
Status: Errored
Duration: 50 minutes and 3 seconds
Commit: 8693e21 (master)
Author: xqt
Message: [IMPROV] Enable new watchlist parameters (MW 1.16+)
- improvement of Page.save method to enable all values for api
watchlist (including "preferences" and "nochange").
site.editpage() and api already use it.
- rename Page._save parameter "watchval" to common "watch". The
internal _save method should never be used outside, so the
renaming shouldn't care.
- backward compatibility for boolean watch parameter
see also https://www.mediawiki.org/w/index.php?title=API:Edit#Parameters
bug: T98830
Change-Id: Icf482b888829495e76813532f28da6bbf0525891
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/164a0eddebc0...8693e21f…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/62676051
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
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,
--
To view, visit https://gerrit.wikimedia.org/r/211086
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ife80707deeaebe9eb60572943dba5965bc973fd2
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Enable new watchlist parameters (MW 1.16+)
......................................................................
[IMPROV] Enable new watchlist parameters (MW 1.16+)
- improvement of Page.save method to enable all values for api
watchlist (including "preferences" and "nochange").
site.editpage() and api already use it.
- rename Page._save parameter "watchval" to common "watch". The
internal _save method should never be used outside, so the
renaming shouldn't care.
- backward compatibility for boolean watch parameter
see also https://www.mediawiki.org/w/index.php?title=API:Edit#Parameters
bug: T98830
Change-Id: Icf482b888829495e76813532f28da6bbf0525891
---
M pywikibot/page.py
1 file changed, 20 insertions(+), 14 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index db5a1ef..389e3c2 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1013,10 +1013,18 @@
@param summary: The edit summary for the modification (optional, but
most wikis strongly encourage its use)
@type summary: unicode
- @param watch: if True, add or if False, remove this Page to/from bot
- user's watchlist; if None (default), follow bot account's default
- settings
- @type watch: bool or None
+ @param watch: Specify how the watchlist is affected by this edit, set
+ to one of "watch", "unwatch", "preferences", "nochange":
+ * watch: add the page to the watchlist
+ * unwatch: remove the page from the watchlist
+ * preferences: use the preference settings (Default)
+ * nochange: don't change the watchlist
+ If None (default), follow bot account's default settings
+
+ For backward compatibility watch parameter may also be boolean:
+ if True, add or if False, remove this Page to/from bot
+ user's watchlist.
+ @type watch: string, bool (deprecated) or None
@param minor: if True, mark this edit as minor
@type minor: bool
@param botflag: if True, mark this edit as made by a bot (default:
@@ -1035,25 +1043,23 @@
"""
if not summary:
summary = config.default_edit_summary
- if watch is None:
- watchval = None
- elif watch:
- watchval = "watch"
- else:
- watchval = "unwatch"
+ if watch is True:
+ watch = 'watch'
+ elif watch is False:
+ watch = 'unwatch'
if not force and not self.botMayEdit():
raise pywikibot.OtherPageSaveError(
self, "Editing restricted by {{bots}} template")
if async:
pywikibot.async_request(self._save, summary=summary, minor=minor,
- watchval=watchval, botflag=botflag,
+ watch=watch, botflag=botflag,
async=async, callback=callback, **kwargs)
else:
- self._save(summary=summary, minor=minor, watchval=watchval,
+ self._save(summary=summary, minor=minor, watch=watch,
botflag=botflag, async=async, callback=callback,
**kwargs)
- def _save(self, summary, minor, watchval, botflag, async, callback,
+ def _save(self, summary, minor, watch, botflag, async, callback,
**kwargs):
"""Helper function for save()."""
err = None
@@ -1062,7 +1068,7 @@
summary = self._cosmetic_changes_hook(summary) or summary
try:
done = self.site.editpage(self, summary=summary, minor=minor,
- watch=watchval, bot=botflag, **kwargs)
+ watch=watch, bot=botflag, **kwargs)
if not done:
pywikibot.warning(u"Page %s not saved" % link)
raise pywikibot.PageNotSaved(self)
--
To view, visit https://gerrit.wikimedia.org/r/210281
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icf482b888829495e76813532f28da6bbf0525891
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Helder.wiki <helder.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>