jenkins-bot has submitted this change and it was merged.
Change subject: solve_disambiguation.py: Do not suggest duplicate alternatives
......................................................................
solve_disambiguation.py: Do not suggest duplicate alternatives
Bug: T138667
Change-Id: I137adebe9a8941db40e84a9785073693a6e3d487
---
M scripts/solve_disambiguation.py
1 file changed, 13 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index 92d8938..74ad11b 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -71,7 +71,7 @@
# (C) Daniel Herding, 2004
# (C) Andre Engels, 2003-2004
# (C) WikiWichtel, 2004
-# (C) Pywikibot team, 2003-2015
+# (C) Pywikibot team, 2003-2016
#
# Distributed under the terms of the MIT license.
#
@@ -651,9 +651,16 @@
return None
def makeAlternativesUnique(self):
- """Remove duplicate entries stable."""
- unique = set(self.alternatives)
- self.alternatives = [alt for alt in self.alternatives if alt in unique]
+ """Remove duplicate items from self.alternatives.
+
+ Preserve the order of alternatives.
+ @rtype: None
+
+ """
+ seen = set()
+ self.alternatives = [
+ i for i in self.alternatives if i not in seen and not seen.add(i)
+ ]
def listAlternatives(self):
"""Show a list of alternatives."""
@@ -954,7 +961,7 @@
def findAlternatives(self, disambPage):
"""Extend self.alternatives using correctcap of
disambPage.linkedPages.
- @param disambPage: the disabiguation page
+ @param disambPage: the disambiguation page
@type disambPage: pywikibot.Page
@return: True if everything goes fine, False otherwise
@rtype: bool
@@ -1002,6 +1009,7 @@
u"The specified page is not a redirect. Skipping.")
return False
elif self.getAlternatives:
+ # not disambPage.isRedirectPage() or self.primary
try:
if self.primary:
try:
--
To view, visit
https://gerrit.wikimedia.org/r/299277
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I137adebe9a8941db40e84a9785073693a6e3d487
Gerrit-PatchSet: 2
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>