jenkins-bot has submitted this change and it was merged.
Change subject: Fix case of some first words
......................................................................
Fix case of some first words
Bug: T121365
Change-Id: I047ca83e445c32b230e6d6a10263d2e71916cefd
---
M pywikibot/bot_choice.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index 17c799d..194ac53 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -202,12 +202,12 @@
@property
def minimum(self):
- """return the minimum value."""
+ """Return the minimum value."""
return self._min
@property
def maximum(self):
- """return the maximum value."""
+ """Return the maximum value."""
return self._max
def format(self, default):
@@ -301,7 +301,7 @@
@property
def maximum(self):
- """return the maximum value."""
+ """Return the maximum value."""
return len(self._list)
def result(self, value):
--
To view, visit https://gerrit.wikimedia.org/r/263174
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I047ca83e445c32b230e6d6a10263d2e71916cefd
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mehtab98 <mehtab.zafar98(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Page repr tests: Enforce console encoding
......................................................................
[IMPROV] Page repr tests: Enforce console encoding
When backporting 38589d3 to the 2.0 branch, an error occurred on the Jenkins
tests because the console encoding wasn't the expected value. Now for some
reason this is not a problem in the master branch, but in case someone uses a
custom console encoding it might fail even though it shouldn't. So this is now
enforcing the UTF-8 console encoding.
Change-Id: Ia642c34b67bf7edd0da9240a80552911b9e79918
---
M tests/page_tests.py
1 file changed, 11 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/page_tests.py b/tests/page_tests.py
index 1cc6248..48829f9 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -570,6 +570,17 @@
"""Test for Page's repr implementation."""
+ def setUp(self):
+ """Force the console encoding to UTF-8."""
+ super(TestPageRepr, self).setUp()
+ self._old_encoding = config.console_encoding
+ config.console_encoding = 'utf8'
+
+ def tearDown(self):
+ """Restore the original console encoding."""
+ config.console_encoding = self._old_encoding
+ super(TestPageRepr, self).tearDown()
+
def test_mainpage_type(self):
u"""Test the return type of repr(Page(<main page>)) is str."""
mainpage = self.get_mainpage()
--
To view, visit https://gerrit.wikimedia.org/r/263157
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia642c34b67bf7edd0da9240a80552911b9e79918
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: site.py: Support titles parameter in watch action
......................................................................
site.py: Support titles parameter in watch action
Deprecate 'watchpage' method and add 'watch' as replacement.
In the 'watch' method:
- Handle multiple pages.
- Use 'titles' instead of 'title' for mw 1.23+ API calls.
- Iterate over all pages for mw versions < 1.23.
Use the 'watch' method in BasePage().watch.
In the new implementation, an exception is raised if an unexpected
API response is received (instead of just showing a UI error as
'watchpage' does).
Changing the UI error to an exception could not be implemented in
the old 'watchpage' method without introducing a, although slight,
breaking change. See John Vandenberg's comment at T103736#1917344.
Other than that, 's.watch(pages)' feels more intuitive than
's.watchpage(pages)'.
Bug: T103736
Change-Id: I75621972f23509a7e6c843e69abad52025546526
---
M pywikibot/page.py
M pywikibot/site.py
2 files changed, 45 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 34f30b6..811bc46 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1240,7 +1240,7 @@
@return: bool; True if successful, False otherwise.
"""
- return self.site.watchpage(self, unwatch)
+ return self.site.watch(self, unwatch)
def purge(self, **kwargs):
"""Purge the server's cache for this page.
diff --git a/pywikibot/site.py b/pywikibot/site.py
index a7c0bd4..8cd2aa8 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -5387,16 +5387,58 @@
return data
@must_be(group='user')
+ def watch(self, pages, unwatch=False):
+ """Add or remove pages from watchlist.
+
+ @param pages: A single page or a sequence of pages.
+ @type pages: A page object, a page-title string, or sequence of them.
+ Also accepts a single pipe-separated string like 'title1|title2'.
+ @param unwatch: If True, remove pages from watchlist;
+ if False add them (default).
+ @return: True if API returned expected response; False otherwise
+ @rtype: bool
+
+ """
+ parameters = {'action': 'watch',
+ 'token': self.tokens['watch'],
+ 'unwatch': unwatch}
+ unwatch = 'unwatched' if unwatch else 'watched'
+ if MediaWikiVersion(self.version()) >= MediaWikiVersion('1.23'):
+ parameters['titles'] = pages
+ req = self._simple_request(**parameters)
+ results = req.submit()
+ return all(unwatch in r for r in results['watch'])
+
+ # MW version < 1.23
+ if isinstance(pages, str):
+ if '|' in pages:
+ pages = pages.split('|')
+ else:
+ pages = (pages,)
+
+ for page in pages:
+ parameters['title'] = page
+ req = self._simple_request(**parameters)
+ result = req.submit()
+ if unwatch not in result['watch']:
+ return False
+ return True
+
+ @must_be(group='user')
+ @deprecated('Site().watch')
def watchpage(self, page, unwatch=False):
"""Add or remove page from watchlist.
+ DEPRECATED: Use Site().watch() instead.
+
+ @param page: A single page.
+ @type page: A page object, a page-title string.
@param unwatch: If True, remove page from watchlist; if False (default),
add it.
@return: True if API returned expected response; False otherwise
+ @rtype: bool
"""
- # TODO: Separated parameters to allow easy conversion to 'watchpages'
- # as the API now allows 'titles'.
parameters = {'action': 'watch',
'title': page,
'token': self.tokens['watch'],
--
To view, visit https://gerrit.wikimedia.org/r/261904
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I75621972f23509a7e6c843e69abad52025546526
Gerrit-PatchSet: 23
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Add docstring for cosmetic_changes.CosmeticChangesToolkit.cleanUpLinks
......................................................................
Add docstring for cosmetic_changes.CosmeticChangesToolkit.cleanUpLinks
Bug: T118423
Change-Id: I1b655412a4dfaf4c287658d5a012d3bbb46de7e7
---
M pywikibot/cosmetic_changes.py
1 file changed, 20 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 8aabc09..f466b89 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -467,6 +467,26 @@
return text
def cleanUpLinks(self, text):
+ """Tidy up wikilinks found in a string.
+
+ This function will:
+ * Replace underscores with spaces
+
+ * Move leading and trailing spaces out of the wikilink and into the
+ surrounding text
+
+ * Convert URL-encoded characters into Unicode-encoded characters
+
+ * Move trailing characters out of the link and make the link without
+ using a pipe, if possible
+
+ * Capitalize the article title of the link, if appropriate
+
+ @param text: string to perform the clean-up on
+ @type text: str
+ @return: text with tidied wikilinks
+ @rtype: str
+ """
# helper function which works on one link and either returns it
# unmodified, or returns a replacement.
def handleOneLink(match):
--
To view, visit https://gerrit.wikimedia.org/r/262668
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1b655412a4dfaf4c287658d5a012d3bbb46de7e7
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Sn1per <geofbot(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Use new test topic for reply tests
......................................................................
Use new test topic for reply tests
The topic on the testwiki used to test replying has become too big.
The size of the topic is slowing down reply tests. This patch points
the reply tests to a new topic in order to speed them up.
Unless someone can purge the posts from the topic, patches such as
this one will be necessary periodically.
Change-Id: Icf84daa1ec0eb855370e10902b82cbb43ae7af43
---
M tests/flow_edit_tests.py
1 file changed, 11 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/flow_edit_tests.py b/tests/flow_edit_tests.py
index 5ae7a54..5c36c3f 100644
--- a/tests/flow_edit_tests.py
+++ b/tests/flow_edit_tests.py
@@ -49,11 +49,17 @@
user = True
write = True
+ @classmethod
+ def setUpClass(cls):
+ """Set up class."""
+ super(TestFlowReply, cls).setUpClass()
+ cls._topic_title = 'Topic:Stf56oxx0sd4dkj1'
+
def test_reply_to_topic(self):
"""Test replying to "topic" (really the topic's root post)."""
# Setup
content = 'I am a reply to the topic. Replying works!'
- topic = Topic(self.site, 'Topic:Sl4ssgh123c3e1bh')
+ topic = Topic(self.site, self._topic_title)
old_replies = topic.replies(force=True)[:]
# Reply
reply_post = topic.reply(content, 'wikitext')
@@ -71,7 +77,7 @@
"""Test replying to the topic's root post directly."""
# Setup
content = "I am a reply to the topic's root post. Replying still works!"
- topic = Topic(self.site, 'Topic:Sl4ssgh123c3e1bh')
+ topic = Topic(self.site, self._topic_title)
topic_root = topic.root
old_replies = topic_root.replies(force=True)[:]
# Reply
@@ -90,8 +96,8 @@
"""Test replying to an ordinary post."""
# Setup
content = 'I am a nested reply to a regular post. Still going strong!'
- topic = Topic(self.site, 'Topic:Sl4ssgh123c3e1bh')
- root_post = Post(topic, 'smjnql768bl0h0kt')
+ topic = Topic(self.site, self._topic_title)
+ root_post = Post(topic, 'stf5bamzx32rj1gt')
old_replies = root_post.replies(force=True)[:]
# Reply
reply_post = root_post.reply(content, 'wikitext')
@@ -110,7 +116,7 @@
# Setup
first_content = 'I am a reply to the topic with my own replies. Great!'
second_content = 'I am a nested reply. This conversation is getting pretty good!'
- topic = Topic(self.site, 'Topic:Sl4ssgh123c3e1bh')
+ topic = Topic(self.site, self._topic_title)
topic_root = topic.root
# First reply
old_root_replies = topic_root.replies(force=True)[:]
--
To view, visit https://gerrit.wikimedia.org/r/255529
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icf84daa1ec0eb855370e10902b82cbb43ae7af43
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Happy5214 <happy5214(a)gmail.com>
Gerrit-Reviewer: Happy5214 <happy5214(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>