jenkins-bot has submitted this change and it was merged.
Change subject: [BREAKING] Change default behavior of set_redirect_target
......................................................................
[BREAKING] Change default behavior of set_redirect_target
Now there is another argument named 'save' and default is true.
If it's false, it doesn't save the page but when it's true, it saves page
immediately.
Any usage of this method which doesn't determine any additional
argument would change their behavior and saves immediately instead of
just changing the page.text.
It is useful since most of the time, we don't need more changes after
creating or changing a redirect page.
Change-Id: Iaadfa03d6ef7a8252ff4df7fc5281e222642ebc3
---
M pywikibot/page.py
M scripts/redirect.py
2 files changed, 7 insertions(+), 8 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
Ladsgroup: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index e089fc2..0136a32 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1946,15 +1946,12 @@
return result
def set_redirect_target(self, target_page, create=False, force=False,
- keep_section=False, **kwargs):
+ keep_section=False, save=True, **kwargs):
"""
Change the page's text to point to the redirect page.
@param target_page: target of the redirect, this argument is required.
@type target_page: pywikibot.Page or string
- @param summary: The edit summary which must be set if the page should
- be saved too. If omitted the page won't be saved.
- @type summary: string
@param create: if true, it creates the redirect even if the page
doesn't exist.
@type create: bool
@@ -1964,8 +1961,10 @@
@param keep_section: if the old redirect links to a section
and the new one doesn't it uses the old redirect's section.
@type keep_section: bool
+ @param save: if true, it saves the page immediately.
+ @type save: bool
@param kwargs: Arguments which are used for saving the page directly
- afterwards. If none are provided the page isn't saved.
+ afterwards, like 'summary' for edit summary.
"""
if isinstance(target_page, basestring):
target_page = pywikibot.Page(self.site, target_page)
@@ -1999,7 +1998,7 @@
allowInterwiki=False)
target_link = u'#{0} {1}'.format(self.site.redirect(), target_link)
self.text = prefix + target_link + suffix
- if kwargs:
+ if save:
self.save(**kwargs)
diff --git a/scripts/redirect.py b/scripts/redirect.py
index ec99198..2dcaa34 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -456,7 +456,7 @@
asLink=True)})
content = redir_page.get(get_redirect=True)
redir_page.set_redirect_target(
- movedTarget, keep_section=True)
+ movedTarget, keep_section=True, save=False)
pywikibot.showDiff(content, redir_page.text)
pywikibot.output(u'Summary - %s' % reason)
if self.user_confirm(
@@ -640,7 +640,7 @@
except pywikibot.BadTitle:
pywikibot.output(u"Bad Title Error")
break
- redir.set_redirect_target(targetPage, keep_section=True)
+ redir.set_redirect_target(targetPage, keep_section=True, save=False)
summary = i18n.twtranslate(self.site, 'redirect-fix-double',
{'to': targetPage.title(asLink=True)}
)
--
To view, visit https://gerrit.wikimedia.org/r/206081
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaadfa03d6ef7a8252ff4df7fc5281e222642ebc3
Gerrit-PatchSet: 10
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Don't break cosmetic_changes for InvalidIsbnException
......................................................................
Don't break cosmetic_changes for InvalidIsbnException
isbn.format may fail for unknown publishers. But this should not
break the script except strict parameter is set.
Since cosmetic_changes may called by other scripts, set the lowest
cancel level to break and ignore its changes.
bug: T97836
Change-Id: I68c43f2602fc1dbaef375017c9cb3fb50ca60252
---
M pywikibot/page.py
M scripts/cosmetic_changes.py
2 files changed, 9 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 781c3a0..fb3887b 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1097,7 +1097,8 @@
ccToolkit = CosmeticChangesToolkit(self.site,
redirect=self.isRedirectPage(),
namespace=self.namespace(),
- pageTitle=self.title())
+ pageTitle=self.title(),
+ ignore=3) # CANCEL_MATCH
self.text = ccToolkit.change(old)
if comment and \
old.strip().replace('\r\n',
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 970cfbc..84e7db1 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -66,7 +66,7 @@
cosmetic_changes_deny_script += ['your_script_name_1', 'your_script_name_2']
"""
#
-# (C) xqt, 2009-2013
+# (C) xqt, 2009-2015
# (C) Pywikibot team, 2006-2015
#
# Distributed under the terms of the MIT license.
@@ -198,7 +198,12 @@
return isbn
isbn = scripts_isbn.getIsbn(isbn)
- isbn.format()
+ try:
+ isbn.format()
+ except scripts_isbn.InvalidIsbnException as e:
+ if strict:
+ raise
+ pywikibot.log('ISBN "%s" validation error: %s' % (isbn, e))
return isbn.code
--
To view, visit https://gerrit.wikimedia.org/r/208357
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I68c43f2602fc1dbaef375017c9cb3fb50ca60252
Gerrit-PatchSet: 1
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] hastemplate() returns true for even one existing template
......................................................................
[bugfix] hastemplate() returns true for even one existing template
- Don't care about remove_tl. We may remove them anyway.
- Care about the first item. It must exist because that one is
added to the paqe.
bug: T98073
Change-Id: Ic9933c384233e58e03bca6404e5ba53f454976e4
---
M scripts/featured.py
1 file changed, 11 insertions(+), 8 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/featured.py b/scripts/featured.py
index ed6347d..9e534b7 100755
--- a/scripts/featured.py
+++ b/scripts/featured.py
@@ -297,15 +297,18 @@
def hastemplate(self, task):
add_tl, remove_tl = self.getTemplateList(self.site.code, task)
- for tl in add_tl:
+ for i, tl in enumerate(add_tl):
tp = pywikibot.Page(self.site, tl, ns=10)
- if not tp.exists():
- return
- for tl in remove_tl:
- tp = pywikibot.Page(self.site, tl, ns=10)
- if not tp.exists():
- return
- return True
+ if tp.exists():
+ return True
+ else:
+ pywikibot.output(tl + ' does not exist')
+ # The first item is the default template to be added.
+ # It must exist. Otherwise the script must not run.
+ if i == 0:
+ return
+ else:
+ return
def readcache(self, task):
if self.getOption('count') or self.getOption('nocache') is True:
--
To view, visit https://gerrit.wikimedia.org/r/208921
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic9933c384233e58e03bca6404e5ba53f454976e4
Gerrit-PatchSet: 4
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: [FIX] Page: Return cached text if possible
......................................................................
[FIX] Page: Return cached text if possible
This returns the cached text from Page.get() instead of requesting it
each time again (of course unless forced). Also Page.get() does request
the text for the first time twice which is reduced to one request.
This change makes Page.latest_revision also returned a cached revision
which was changed into a non-cached version in 1de1e560.
Bug: T97960
Change-Id: I762009859f505dda85f680bbfae2ea38a2e04e2d
---
M pywikibot/page.py
1 file changed, 12 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 5195f59..26fdf3d 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -361,6 +361,14 @@
return self.latest_revision.text
+ def _latest_cached_revision(self):
+ """Get the latest revision if cached and has text, otherwise None."""
+ if (hasattr(self, '_revid') and self._revid in self._revisions and
+ self._revisions[self._revid].text is not None):
+ return self._revisions[self._revid]
+ else:
+ return None
+
def _getInternals(self, sysop):
"""Helper function for get().
@@ -374,9 +382,7 @@
raise self._getexception
# If not already stored, fetch revision
- if not hasattr(self, "_revid") \
- or self._revid not in self._revisions \
- or self._revisions[self._revid].text is None:
+ if self._latest_cached_revision() is None:
try:
self.site.loadrevisions(self, getText=True, sysop=sysop)
except (pywikibot.NoPage, pywikibot.SectionError) as e:
@@ -439,6 +445,9 @@
@property
def latest_revision(self):
"""Return the current revision for this page."""
+ rev = self._latest_cached_revision()
+ if rev is not None:
+ return rev
return next(self.revisions(content=True, total=1))
@property
--
To view, visit https://gerrit.wikimedia.org/r/208574
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I762009859f505dda85f680bbfae2ea38a2e04e2d
Gerrit-PatchSet: 2
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
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: Allow RC tests to be skipped on any site
......................................................................
Allow RC tests to be skipped on any site
Restore fr.wiktionary builds, without RC tests,
as ar.wiktionary has not triggered T92856.
Change-Id: Ibb465a4280e97d6f0569b5da788ad1d019fd0d4a
---
M .travis.yml
M tests/aspects.py
M tests/pagegenerators_tests.py
3 files changed, 25 insertions(+), 25 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.travis.yml b/.travis.yml
index fc28d39..5123197 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -79,7 +79,7 @@
- secure: kofInMlisiTBt9o/Ustc/vySlkKfxGzGCX2LwA1D2waym8sDTS0o5gMJ5LsrT/BUKwZbe1vLozPHqZrrkQvsdTml+DpZuotzdILs0m0f3BUoexEC6OON5IDljuxFyETrD1Ug44ih5Mc4lVFOdTcBzg501ZmswGwQrBvg/OyEFfE=
matrix:
- LANGUAGE=en FAMILY=wikipedia EXTERNALS_HTTPLIB2=1 PYWIKIBOT2_TEST_PROD_ONLY=1
- - LANGUAGE=fr FAMILY=wikipedia PYSETUP_TEST_EXTRAS=1 PYWIKIBOT2_TEST_PROD_ONLY=1
+ - LANGUAGE=fr FAMILY=wiktionary PYSETUP_TEST_EXTRAS=1 PYWIKIBOT2_TEST_PROD_ONLY=1 PYWIKIBOT2_TEST_NO_RC=1
- LANGUAGE=wikidata FAMILY=wikidata SITE_ONLY=1
- LANGUAGE=ar FAMILY=wiktionary SITE_ONLY=1 EXTERNALS_HTTPLIB2=1
diff --git a/tests/aspects.py b/tests/aspects.py
index 0af24b4..c0a241c 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -1186,6 +1186,26 @@
return execute_pwb(args, data_in, timeout, error)
+class RecentChangesTestCase(WikimediaDefaultSiteTestCase):
+
+ """Test cases for tests that use recent change."""
+
+ # site.recentchanges() includes external edits from wikidata,
+ # except on wiktionaries which are not linked to wikidata
+ # so total=3 should not be too high for most sites.
+ length = 3
+
+ @classmethod
+ def setUpClass(cls):
+ if os.environ.get('PYWIKIBOT2_TEST_NO_RC', '0') == '1':
+ raise unittest.SkipTest('RecentChanges tests disabled.')
+
+ super(RecentChangesTestCase, cls).setUpClass()
+
+ if cls.get_site().code == 'test':
+ cls.override_default_site(pywikibot.Site('en', 'wikipedia'))
+
+
class DebugOnlyTestCase(TestCase):
"""Test cases that only operate in debug mode."""
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index b76c955..967b95e 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -30,7 +30,7 @@
DeprecationTestCase,
WikidataTestCase,
DefaultSiteTestCase,
- WikimediaDefaultSiteTestCase,
+ RecentChangesTestCase,
)
from tests.thread_tests import GeneratorIntersectTestCase
@@ -232,21 +232,9 @@
self.assertEqual(len(list(gen)), 0)
-class TestRepeatingGenerator(WikimediaDefaultSiteTestCase):
+class TestRepeatingGenerator(RecentChangesTestCase):
"""Test RepeatingGenerator."""
-
- # site.recentchanges() includes external edits from wikidata,
- # except on wiktionaries which are not linked to wikidata
- # so total=3 should not be too high for most sites.
- length = 3
-
- @classmethod
- def setUpClass(cls):
- super(TestRepeatingGenerator, cls).setUpClass()
-
- if cls.get_site().code == 'test':
- cls.override_default_site(pywikibot.Site('en', 'wikipedia'))
def test_RepeatingGenerator(self):
items = list(
@@ -835,14 +823,9 @@
)
-class LiveRCPageGeneratorTestCase(WikimediaDefaultSiteTestCase):
+class LiveRCPageGeneratorTestCase(RecentChangesTestCase):
- """Test case for Live Recent Changes pagegenerator.
-
- Works best on a busy site, as three changes are requested
- """
-
- length = 3
+ """Test case for Live Recent Changes pagegenerator."""
@classmethod
def setUpClass(cls):
@@ -856,9 +839,6 @@
raise unittest.SkipTest(
'socketIO_client %s not supported by Wikimedia-Stream'
% socketIO_client.__version__)
-
- if cls.get_site().code == 'test':
- cls.override_default_site(pywikibot.Site('en', 'wikipedia'))
def test_RC_pagegenerator_result(self):
import logging
--
To view, visit https://gerrit.wikimedia.org/r/208916
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibb465a4280e97d6f0569b5da788ad1d019fd0d4a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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 <>
John Vandenberg has submitted this change and it was merged.
Change subject: Set executable bits on top level entry points
......................................................................
Set executable bits on top level entry points
Add /usr/bin/python shebang while at it.
Change-Id: I3b6a071cc2d953f69b9860b75c1062448c6df254
---
M generate_family_file.py
M generate_user_files.py
M pwb.py
3 files changed, 2 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
Hashar: Looks good to me, but someone else must approve
jenkins-bot: Verified
Objections:
XZise: There's a problem with this change, please improve
diff --git a/generate_family_file.py b/generate_family_file.py
old mode 100644
new mode 100755
index 3f8e949..4993fd6
--- a/generate_family_file.py
+++ b/generate_family_file.py
@@ -1,3 +1,4 @@
+#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
This script generates a family file from a given URL.
diff --git a/generate_user_files.py b/generate_user_files.py
old mode 100644
new mode 100755
diff --git a/pwb.py b/pwb.py
old mode 100644
new mode 100755
index b15b927..b96b002
--- a/pwb.py
+++ b/pwb.py
@@ -1,3 +1,4 @@
+#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Wrapper script to use Pywikibot in 'directory' mode.
--
To view, visit https://gerrit.wikimedia.org/r/205075
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3b6a071cc2d953f69b9860b75c1062448c6df254
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Hashar <hashar(a)free.fr>
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 <>
saper has submitted this change and it was merged.
Change subject: (bug T63231) use OSError as WindowsError does not exist on unix hosts
......................................................................
(bug T63231) use OSError as WindowsError does not exist on unix hosts
Change-Id: I17d0352a221e68df5b64b324a48bd82e1d76fb65
---
M pywikibot/version.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
saper: Verified; Looks good to me, approved
diff --git a/pywikibot/version.py b/pywikibot/version.py
index ee49fe7..55a2ee0 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -178,7 +178,7 @@
date = None
try:
subprocess.Popen([cmd], stdout=subprocess.PIPE).communicate()
- except WindowsError:
+ except OSError:
# some windows git versions provide git.cmd instead of git.exe
cmd = 'git.cmd'
try:
--
To view, visit https://gerrit.wikimedia.org/r/208839
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I17d0352a221e68df5b64b324a48bd82e1d76fb65
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: saper <saper(a)saper.info>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
Gerrit-Reviewer: saper <saper(a)saper.info>
jenkins-bot has submitted this change and it was merged.
Change subject: Use /usr/bin/python as the shebang
......................................................................
Use /usr/bin/python as the shebang
30d1df9d4f8942ff489cc0c101c2026206cd4440 normalised all shebangs
to /usr/bin/python, except these two scripts.
Change-Id: Ie28add198c4645324eeef6abb1fe0c85623667bf
---
M scripts/archivebot.py
M scripts/replicate_wiki.py
2 files changed, 2 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 22d9af7..6c48ccb 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
archivebot.py - discussion page archiving bot.
diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py
index aef3948..c890910 100755
--- a/scripts/replicate_wiki.py
+++ b/scripts/replicate_wiki.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
This bot replicates pages in a wiki to a second wiki within one family.
--
To view, visit https://gerrit.wikimedia.org/r/205074
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie28add198c4645324eeef6abb1fe0c85623667bf
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Hashar <hashar(a)free.fr>
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>