jenkins-bot has submitted this change and it was merged.
Change subject: Comparable to delegate to other
......................................................................
Comparable to delegate to other
The Comparable mixin currently depends on `other` also being Comparable.
It did not check that they were of the same class.
It should let `other` decide how comparison should be done with the
value of self._cmpkey(). This is slightly less efficient, but allows
comparision with any object which is comparable with self._cmpkey(),
which includes other objects of the same class as they should both have
the same object type in self._cmpkey().
Change-Id: Id33df6c848479bc3b589a0e282a6a05ca84c22ba
---
M pywikibot/tools.py
1 file changed, 7 insertions(+), 15 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/pywikibot/tools.py b/pywikibot/tools.py
index 9254200..b90cc5e 100644
--- a/pywikibot/tools.py
+++ b/pywikibot/tools.py
@@ -52,33 +52,25 @@
# From http://python3porting.com/preparing.html
class ComparableMixin(object):
- """Mixin class to allow comparing to other objects of this class."""
-
- def _compare(self, other, method):
- try:
- return method(self._cmpkey(), other._cmpkey())
- except (AttributeError, TypeError):
- # _cmpkey not implemented, or return different type,
- # so I can't compare with "other".
- return NotImplemented
+ """Mixin class to allow comparing to other objects which are comparable."""
def __lt__(self, other):
- return self._compare(other, lambda s, o: s < o)
+ return other >= self._cmpkey()
def __le__(self, other):
- return self._compare(other, lambda s, o: s <= o)
+ return other > self._cmpkey()
def __eq__(self, other):
- return self._compare(other, lambda s, o: s == o)
+ return other == self._cmpkey()
def __ge__(self, other):
- return self._compare(other, lambda s, o: s >= o)
+ return other < self._cmpkey()
def __gt__(self, other):
- return self._compare(other, lambda s, o: s > o)
+ return other <= self._cmpkey()
def __ne__(self, other):
- return self._compare(other, lambda s, o: s != o)
+ return other != self._cmpkey()
class MediaWikiVersion(Version):
--
To view, visit https://gerrit.wikimedia.org/r/170724
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id33df6c848479bc3b589a0e282a6a05ca84c22ba
Gerrit-PatchSet: 2
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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: Script test checks: import ImageTk from PIL
......................................................................
Script test checks: import ImageTk from PIL
Replace 'import ImageTk' with 'import PIL.ImageTk' in dependency
checks used by script_tests.py
Bug: 71864
Change-Id: Icde45330c5e1ac22c77a55be94d531ad509a66c2
---
M tests/script_tests.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index b46e647..07aba13 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -26,7 +26,7 @@
'script_wui': ['crontab', 'lua'],
# Note: package 'lunatic-python' provides module 'lua'
- 'flickrripper': ['ImageTk', 'flickrapi'],
+ 'flickrripper': ['PIL.ImageTk', 'flickrapi'],
# Note: 'PIL' is not available via pip2.7 on MS Windows,
# however it is available with setuptools.
}
--
To view, visit https://gerrit.wikimedia.org/r/170647
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icde45330c5e1ac22c77a55be94d531ad509a66c2
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: 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: Use Namespace as a key into Site.namespaces
......................................................................
Use Namespace as a key into Site.namespaces
Existing code uses a namespace variable, consisting of an int, as
a key into the Site.namespaces dict. In order to change these
namespace variables to be a Namespace object instead of an int,
the Namespace object needs to be usable as a key.
Change-Id: Ib30da3c1e8fb0fef2e5efd8d06313f8852802934
---
M pywikibot/site.py
M tests/namespace_tests.py
2 files changed, 6 insertions(+), 0 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/pywikibot/site.py b/pywikibot/site.py
index 3717449..8cf9f60 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -299,6 +299,9 @@
def __index__(self):
return self.id
+ def __hash__(self):
+ return self.id
+
def __eq__(self, other):
"""Compare whether two namespace objects are equal."""
if isinstance(other, int):
diff --git a/tests/namespace_tests.py b/tests/namespace_tests.py
index e3c3f60..c33a6e3 100644
--- a/tests/namespace_tests.py
+++ b/tests/namespace_tests.py
@@ -81,6 +81,9 @@
self.assertTrue(all(Namespace.lookup_name(b, ns).id == self.all_builtin_ids[b]
for b in self.all_builtin_ids))
+ # Use a namespace object as a dict key
+ self.assertEqual(ns[ns[6]], ns[6])
+
def testNamespaceConstructor(self):
kwargs = {u'case': u'first-letter'}
y = Namespace(id=6, custom_name=u'dummy', canonical_name=u'File',
--
To view, visit https://gerrit.wikimedia.org/r/170704
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib30da3c1e8fb0fef2e5efd8d06313f8852802934
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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: Allow Family name and langs to be class variables
......................................................................
Allow Family name and langs to be class variables
Use new syntax for families which dont have any other __init__ logic.
Remove unnecessary functions, which replicate the logic in Family,
or version() which is no longer needed by Site.
Add test to ensure all Family classes load and have name and langs.
Change-Id: I052164948830396bd9353bc0f044ec43159ee432
---
M pywikibot/families/battlestarwiki_family.py
M pywikibot/families/i18n_family.py
M pywikibot/families/lyricwiki_family.py
M pywikibot/families/omegawiki_family.py
M pywikibot/families/osm_family.py
M pywikibot/families/test_family.py
M pywikibot/families/vikidia_family.py
M pywikibot/families/wikitech_family.py
M pywikibot/family.py
M tests/family_tests.py
10 files changed, 38 insertions(+), 132 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/pywikibot/families/battlestarwiki_family.py b/pywikibot/families/battlestarwiki_family.py
index 44a9182..a5fe75d 100644
--- a/pywikibot/families/battlestarwiki_family.py
+++ b/pywikibot/families/battlestarwiki_family.py
@@ -12,20 +12,9 @@
"""Family class for Battlestar Wiki."""
- def __init__(self):
- """Constructor."""
- family.Family.__init__(self)
- self.name = 'battlestarwiki'
+ name = 'battlestarwiki'
- self.languages_by_size = ['en', 'de', 'fr', 'zh', 'es', 'ms', 'tr', 'simple']
+ languages_by_size = ['en', 'de', 'fr', 'zh', 'es', 'ms', 'tr', 'simple']
- for lang in self.languages_by_size:
- self.langs[lang] = '%s.battlestarwiki.org' % lang
-
- def hostname(self, code):
- """Return the hostname for a site in this family."""
- return '%s.battlestarwiki.org' % code
-
- def version(self, code):
- """Return the version for this family."""
- return "1.16.4"
+ langs = dict([(lang, '%s.battlestarwiki.org' % lang)
+ for lang in languages_by_size])
diff --git a/pywikibot/families/i18n_family.py b/pywikibot/families/i18n_family.py
index 73930a1..31c33e0 100644
--- a/pywikibot/families/i18n_family.py
+++ b/pywikibot/families/i18n_family.py
@@ -11,17 +11,8 @@
"""Family class for Translate Wiki."""
- def __init__(self):
- """Constructor."""
- family.Family.__init__(self)
- self.name = 'i18n'
- self.langs = {
- 'i18n': 'translatewiki.net',
- }
-
- def version(self, code):
- """Return the version for this family."""
- return "1.23alpha"
+ name = 'i18n'
+ langs = {'i18n': 'translatewiki.net'}
def protocol(self, code):
"""Return https as the protocol for this family."""
diff --git a/pywikibot/families/lyricwiki_family.py b/pywikibot/families/lyricwiki_family.py
index a0bfcf9..642e573 100644
--- a/pywikibot/families/lyricwiki_family.py
+++ b/pywikibot/families/lyricwiki_family.py
@@ -14,22 +14,11 @@
"""Family class for LyricWiki."""
- def __init__(self):
- """Constructor."""
- family.Family.__init__(self)
- self.name = 'lyricwiki'
- self.langs = {
- 'en': 'lyrics.wikia.com',
- }
-
- def version(self, code):
- """Return the version for this family."""
- return '1.19.20'
+ name = 'lyricwiki'
+ langs = {
+ 'en': 'lyrics.wikia.com',
+ }
def scriptpath(self, code):
"""Return the script path for this family."""
return ''
-
- def apipath(self, code):
- """Return the path to api.php for this family."""
- return '/api.php'
diff --git a/pywikibot/families/omegawiki_family.py b/pywikibot/families/omegawiki_family.py
index 7661dac..d6b4a8d 100644
--- a/pywikibot/families/omegawiki_family.py
+++ b/pywikibot/families/omegawiki_family.py
@@ -10,36 +10,21 @@
"""Family class for Omega Wiki."""
+ name = 'omegawiki'
+ langs = {'omegawiki': 'www.omegawiki.org'}
+
def __init__(self):
"""Constructor."""
family.Family.__init__(self)
- self.name = 'omegawiki'
- self.langs['omegawiki'] = 'www.omegawiki.org'
# On most Wikipedias page names must start with a capital letter, but some
# languages don't use this.
self.nocapitalize = list(self.langs.keys())
- def hostname(self, code):
- """Return the hostname for this family."""
- return 'www.omegawiki.org'
-
- def version(self, code):
- """Return the version for this family."""
- return "1.22.6"
-
def scriptpath(self, code):
"""Return the script path for this family."""
return ''
-
- def path(self, code):
- """Return the path to index.php for this family."""
- return '/index.php'
-
- def apipath(self, code):
- """Return the path to api.php for this family."""
- return '/api.php'
def protocol(self, code):
"""Return https as the protocol for this family."""
diff --git a/pywikibot/families/osm_family.py b/pywikibot/families/osm_family.py
index fbb9fe6..995c8d6 100644
--- a/pywikibot/families/osm_family.py
+++ b/pywikibot/families/osm_family.py
@@ -11,17 +11,8 @@
"""Family class for OpenStreetMap wiki."""
- def __init__(self):
- """Constructor."""
- family.Family.__init__(self)
- self.name = 'osm'
- self.langs = {
- 'en': 'wiki.openstreetmap.org',
- }
-
- def version(self, code):
- """Return the version for this family."""
- return "1.22.7"
+ name = 'osm'
+ langs = {'en': 'wiki.openstreetmap.org'}
def protocol(self, code):
"""Return https as the protocol for this family."""
diff --git a/pywikibot/families/test_family.py b/pywikibot/families/test_family.py
index 8d72b7c..1517af2 100644
--- a/pywikibot/families/test_family.py
+++ b/pywikibot/families/test_family.py
@@ -10,12 +10,8 @@
"""Family class for test.wikipedia.org."""
- def __init__(self):
- super(Family, self).__init__()
- self.name = 'test'
- self.langs = {
- 'test': 'test.wikipedia.org',
- }
+ name = 'test'
+ langs = {'test': 'test.wikipedia.org'}
def from_url(self, url):
return None # Don't accept this, but 'test' of 'wikipedia'
diff --git a/pywikibot/families/vikidia_family.py b/pywikibot/families/vikidia_family.py
index e02e803..735cd36 100644
--- a/pywikibot/families/vikidia_family.py
+++ b/pywikibot/families/vikidia_family.py
@@ -9,48 +9,15 @@
"""Family class for Vikidia."""
- def __init__(self):
- """Constructor."""
- family.Family.__init__(self)
- self.name = 'vikidia'
+ name = 'vikidia'
- self.langs = {
- 'en': 'en.vikidia.org',
- 'es': 'es.vikidia.org',
- 'fr': 'fr.vikidia.org',
- 'it': 'it.vikidia.org',
- 'ru': 'ru.vikidia.org',
- }
-
- # Wikimedia wikis all use "bodyContent" as the id of the <div>
- # element that contains the actual page content; change this for
- # wikis that use something else (e.g., mozilla family)
- self.content_id = "bodyContent"
-
- def scriptpath(self, code):
- """The prefix used to locate scripts on this wiki.
-
- This is the value displayed when you enter {{SCRIPTPATH}} on a
- wiki page (often displayed at [[Help:Variables]] if the wiki has
- copied the master help page correctly).
-
- The default value is the one used on Wikimedia Foundation wikis,
- but needs to be overridden in the family file for any wiki that
- uses a different value.
-
- """
- return '/w'
-
- # Which version of MediaWiki is used? REQUIRED
- def version(self, code):
- """Return the version for this family."""
- return '1.23.1'
-
- def code2encoding(self, code):
- """Return the encoding for a specific language wiki."""
- # Most wikis nowadays use UTF-8, but change this if yours uses
- # a different encoding
- return 'utf-8'
+ langs = {
+ 'en': 'en.vikidia.org',
+ 'es': 'es.vikidia.org',
+ 'fr': 'fr.vikidia.org',
+ 'it': 'it.vikidia.org',
+ 'ru': 'ru.vikidia.org',
+ }
def protocol(self, code):
"""Return https as the protocol for this family."""
diff --git a/pywikibot/families/wikitech_family.py b/pywikibot/families/wikitech_family.py
index d406f42..4fd054e 100644
--- a/pywikibot/families/wikitech_family.py
+++ b/pywikibot/families/wikitech_family.py
@@ -10,17 +10,8 @@
"""Family class for Wikitech."""
- def __init__(self):
- """Constructor."""
- super(Family, self).__init__()
- self.name = 'wikitech'
- self.langs = {
- 'en': 'wikitech.wikimedia.org',
- }
-
- def version(self, code):
- """Return the version for this family."""
- return '1.21wmf8'
+ name = 'wikitech'
+ langs = {'en': 'wikitech.wikimedia.org'}
def protocol(self, code):
"""Return the protocol for this family."""
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 0501f3e..b3941ff 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -35,6 +35,9 @@
if not hasattr(self, 'name'):
self.name = None
+ if not hasattr(self, 'langs'):
+ self.langs = {}
+
# For interwiki sorting order see
# https://meta.wikimedia.org/wiki/Interwiki_sorting_order
@@ -113,8 +116,6 @@
self.fyinterwiki.remove('nb')
self.fyinterwiki.sort(key=lambda x:
x.replace("y", "i") + x.count("y") * "!")
-
- self.langs = {}
self.namespacesWithSubpage = [2] + list(range(1, 16, 2))
diff --git a/tests/family_tests.py b/tests/family_tests.py
index b8a8c32..3cbadea 100644
--- a/tests/family_tests.py
+++ b/tests/family_tests.py
@@ -26,8 +26,14 @@
def test_family_load_valid(self):
"""Test that a family can be loaded via Family.load."""
- f = Family.load('anarchopedia')
- self.assertEqual(f.name, 'anarchopedia')
+ for name in pywikibot.config.family_files:
+ f = Family.load(name)
+ self.assertIsInstance(f.langs, dict)
+ self.assertNotEqual(f.langs, {})
+ # There is one inconsistency
+ if f.name == 'wikimediachapter' and name == 'wikimedia':
+ continue
+ self.assertEqual(f.name, name)
def test_family_load_invalid(self):
"""Test that an invalid family raised UnknownFamily exception."""
--
To view, visit https://gerrit.wikimedia.org/r/170669
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I052164948830396bd9353bc0f044ec43159ee432
Gerrit-PatchSet: 2
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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: [SYNC] Add category move when the is user is allowed
......................................................................
[SYNC] Add category move when the is user is allowed
similar to core
Change-Id: I0538373d72bdd671211da39e5084c6a1c55c5378
---
M category.py
1 file changed, 9 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/category.py b/category.py
index 3f7043b..090f305 100644
--- a/category.py
+++ b/category.py
@@ -429,7 +429,15 @@
# Copy the category contents to the new category page
copied = False
oldMovedTalk = None
- if self.oldCat.exists() and self.moveCatPage:
+ if (site.isAllowed('move-categorypages') and self.oldCat.exists()
+ and self.moveCatPage):
+ self.oldCat.move(
+ newCat.title(),
+ reason=self.editSummary,
+ movetalkpage=True,
+ leaveRedirect=not self.deleteEmptySourceCat)
+ copied = True
+ elif self.oldCat.exists() and self.moveCatPage:
copied = self.oldCat.copyAndKeep(
newCat.title(), pywikibot.translate(site, cfd_templates))
# Also move the talk page
--
To view, visit https://gerrit.wikimedia.org/r/140805
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0538373d72bdd671211da39e5084c6a1c55c5378
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Calak <Calakwiki(a)yahoo.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Nullzero <nullzero.free(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: delete.py: do not attempt to delete not-existing pages
......................................................................
delete.py: do not attempt to delete not-existing pages
Avoid to process not existing pages when deleting.
Bug: 69134
Change-Id: I593a202fb336bee9e5cbeb27f4601c7c7e80e903
---
M scripts/delete.py
1 file changed, 5 insertions(+), 1 deletion(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/delete.py b/scripts/delete.py
index 4f1e367..5307598 100644
--- a/scripts/delete.py
+++ b/scripts/delete.py
@@ -72,10 +72,14 @@
"""
for page in self.generator:
self.current_page = page
+
if self.getOption('undelete'):
page.undelete(self.summary)
else:
- page.delete(self.summary, not self.getOption('always'))
+ if page.exists():
+ page.delete(self.summary, not self.getOption('always'))
+ else:
+ pywikibot.output(u'Skipping: %s does not exist.' % page)
def main(*args):
--
To view, visit https://gerrit.wikimedia.org/r/170600
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I593a202fb336bee9e5cbeb27f4601c7c7e80e903
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] Advanced link tests
......................................................................
[FEAT] Advanced link tests
With the link tests added in 2a230fc4031e5f116aa954177be22dc1603dd410
this removes all potentional failures added:
- Just the ":"
- If the title contains a section and a namespace prefix but no title
(this is already working when there is no section)
- If the (non-)talk page of the title is actually a title in another
namespace.
Example: Talk:File:Test.png would've the non-talk page File:Test.png
but it's talk page would be File talk:Test.png
Bug: 72681
Change-Id: I3923de0d2930e44ee656e862405b8d654b896fdf
---
M pywikibot/page.py
M tests/link_tests.py
2 files changed, 26 insertions(+), 11 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index eccc9ef..5228395 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -4055,7 +4055,9 @@
"""
self._site = self._source
self._namespace = self._defaultns
+ self._is_interwiki = False
t = self._text
+ ns_prefix = False
# This code was adapted from Title.php : secureAndSplit()
#
@@ -4074,11 +4076,8 @@
if ns:
# Ordinary namespace
t = t[t.index(u":"):].lstrip(u":").lstrip(u" ")
- # 'namespace:' is not a valid title
- if not t:
- raise pywikibot.InvalidTitle(
- u"'{0}' has no title.".format(self._text))
self._namespace = ns
+ ns_prefix = True
break
try:
newsite = self._site.interwiki(prefix)
@@ -4100,12 +4099,29 @@
elif newsite != self._source:
first_other_site = newsite
self._site = newsite
+ self._is_interwiki = True
if u"#" in t:
t, sec = t.split(u'#', 1)
t, self._section = t.rstrip(), sec.lstrip()
else:
self._section = None
+
+ if ns_prefix:
+ # 'namespace:' is not a valid title
+ if not t:
+ raise pywikibot.InvalidTitle(
+ u"'{0}' has no title.".format(self._text))
+ elif ':' in t and self._namespace >= 0: # < 0 don't have talk
+ other_ns = self._site.namespaces[self._namespace - 1
+ if self._namespace % 2 else
+ self._namespace + 1]
+ if '' in other_ns: # other namespace uses empty str as ns
+ next_ns = t[:t.index(':')]
+ if self._site.ns_index(next_ns):
+ raise pywikibot.InvalidTitle(
+ u"The (non-)talk page of '{0}' is a valid title "
+ "in another namespace.".format(self._text))
# Reject illegal characters.
m = Link.illegal_titles_pattern.search(t)
@@ -4139,7 +4155,7 @@
# "empty" local links can only be self-links
# with a fragment identifier.
- if not self._text.strip():
+ if not t.strip() and not self._is_interwiki:
raise pywikibot.InvalidTitle("The link does not contain a page "
"title")
diff --git a/tests/link_tests.py b/tests/link_tests.py
index cb99fe1..a378c65 100644
--- a/tests/link_tests.py
+++ b/tests/link_tests.py
@@ -61,7 +61,7 @@
def test_invalid(self):
self.assertRaises(InvalidTitle, Link('', self.get_site()).parse)
- # TODO: self.assertRaises(InvalidTitle, Link(':', self.get_site()).parse)
+ self.assertRaises(InvalidTitle, Link(':', self.get_site()).parse)
self.assertRaises(InvalidTitle, Link('__ __', self.get_site()).parse)
self.assertRaises(InvalidTitle, Link(' __ ', self.get_site()).parse)
# Bad characters forbidden regardless of wgLegalTitleChars
@@ -74,10 +74,9 @@
# URL encoding
# %XX is understood by wikimedia but not %XXXX
self.assertRaises(InvalidTitle, Link('A%2523B', self.get_site()).parse)
- # Subject of NS_TALK does not roundtrip to NS_MAIN
- # TODO: A link is invalid if their (non-)talk page would be in another
- # namespace than the link's "other" namespace
- # TODO: self.assertRaises(InvalidTitle, Link('Talk:File:Example.svg', self.get_site()).parse)
+ # A link is invalid if their (non-)talk page would be in another
+ # namespace than the link's "other" namespace
+ self.assertRaises(InvalidTitle, Link('Talk:File:Example.svg', self.get_site()).parse)
# Directory navigation
self.assertRaises(InvalidTitle, Link('.', self.get_site()).parse)
self.assertRaises(InvalidTitle, Link('..', self.get_site()).parse)
@@ -97,7 +96,7 @@
# Namespace prefix without actual title
self.assertRaises(InvalidTitle, Link('Talk:', self.get_site()).parse)
self.assertRaises(InvalidTitle, Link('Category: ', self.get_site()).parse)
- # TODO: self.assertRaises(InvalidTitle, Link('Category: #bar', self.get_site()).parse)
+ self.assertRaises(InvalidTitle, Link('Category: #bar', self.get_site()).parse)
# ---- The first set of tests are explicit links, starting with a ':'.
--
To view, visit https://gerrit.wikimedia.org/r/170583
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3923de0d2930e44ee656e862405b8d654b896fdf
Gerrit-PatchSet: 4
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: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>