Xqt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/176477
Change subject: [FEAT] Add -keep option to keep the new link unchanged
......................................................................
[FEAT] Add -keep option to keep the new link unchanged
Normaly solve_disambiguation replaces links by a new one but doesn't
change the appearence. The old link becomes a pipe link to the new
target. Now -keep is able to change both, the link and the content.
Change-Id: I54cc7beec8d9a2037b28d4763dd57a44823fa457
---
M scripts/solve_disambiguation.py
1 file changed, 10 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/77/176477/1
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index fc03782..6308b26 100644
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -38,6 +38,8 @@
searching for alternatives in [[Keyword (disambiguation)]].
Note: this is the same as -primary -just -pos:XY
+ -keep Keep the new title unchanged without creating the pipe link.
+
-file:XYZ reads a list of pages from a text file. XYZ is the name of the
file from which the list is taken. If XYZ is not given, the
user is asked for a filename. Page titles should be inside
@@ -470,7 +472,7 @@
}
def __init__(self, always, alternatives, getAlternatives, dnSkip,
generator,
- primary, main_only, minimum=0):
+ primary, main_only, minimum=0, keep=False):
super(DisambiguationRobot, self).__init__()
self.always = always
self.alternatives = alternatives
@@ -480,6 +482,7 @@
self.primary = primary
self.main_only = main_only
self.minimum = minimum
+ self.keep = keep
self.mysite = pywikibot.Site()
self.mylang = self.mysite.language()
@@ -774,6 +777,8 @@
choice = choice[1:]
elif include == "redirect":
replaceit = True
+ elif self.keep and link_text == page_title:
+ replaceit = True
else:
replaceit = False
@@ -1034,6 +1039,7 @@
alternatives = []
getAlternatives = True
dnSkip = False
+ keep = False
generator = None
pageTitle = None
primary = False
@@ -1078,6 +1084,8 @@
getAlternatives = False
elif arg == '-dnskip':
dnSkip = True
+ elif arg == '-keep':
+ keep = True
elif arg == '-main':
main_only = True
elif arg.startswith('-min:'):
@@ -1113,7 +1121,7 @@
bot = DisambiguationRobot(always, alternatives, getAlternatives, dnSkip,
generator, primary, main_only,
- minimum=minimum)
+ minimum=minimum, keep=keep)
bot.run()
--
To view, visit https://gerrit.wikimedia.org/r/176477
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I54cc7beec8d9a2037b28d4763dd57a44823fa457
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits