jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Use input_choice or input_yn if possible
......................................................................
[IMPROV] Use input_choice or input_yn if possible
Change-Id: I17fb04b9467acecffa98856668f4a92b81978509
---
M scripts/disambredir.py
M scripts/featured.py
2 files changed, 20 insertions(+), 21 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/disambredir.py b/scripts/disambredir.py
index 9e30414..4f3cdcf 100644
--- a/scripts/disambredir.py
+++ b/scripts/disambredir.py
@@ -73,17 +73,15 @@
pywikibot.output(text[max(0, m.start() - context): m.start()] +
'\03{lightred}' + text[m.start(): m.end()] +
'\03{default}' + text[m.end(): m.end() + context])
- while True:
- choice = pywikibot.input(
- u"Option (N=do not change, y=change link to
\03{lightpurple}%s\03{default}, r=change and replace text, u=unlink)"
- % targetPage.title())
- try:
- choice = choice[0]
- except:
- choice = 'N'
- if choice in 'nNyYrRuU':
- break
- if choice in "nN":
+ choice = pywikibot.input_choice(
+ 'What should be done with the link?',
+ (('Do not change', 'n'),
+ ('Change link to \03{lightpurple}%s\03{default}'
+ % targetPage.title(), 'y'),
+ ('Change and replace text', 'r'), ('Unlink',
'u')),
+ default='n', automatic_quit=False)
+
+ if choice == 'n':
continue
# The link looks like this:
@@ -101,20 +99,19 @@
if trailing_chars:
link_text += trailing_chars
- if choice in "uU":
+ if choice == 'u':
# unlink - we remove the section if there's any
text = text[:m.start()] + link_text + text[m.end():]
continue
- replaceit = choice in "rR"
if link_text[0].isupper():
new_page_title = targetPage.title()
else:
new_page_title = (targetPage.title()[0].lower() +
targetPage.title()[1:])
- if replaceit and trailing_chars:
+ if choice == 'r' and trailing_chars:
newlink = "[[%s%s]]%s" % (new_page_title, section, trailing_chars)
- elif replaceit or (new_page_title == link_text and not section):
+ elif choice == 'r' or (new_page_title == link_text and not section):
newlink = "[[%s]]" % new_page_title
# check if we can create a link with trailing characters instead of a
# pipelink
diff --git a/scripts/featured.py b/scripts/featured.py
index 270619c..6de45d6 100644
--- a/scripts/featured.py
+++ b/scripts/featured.py
@@ -559,9 +559,10 @@
else:
# insert just before interwiki
if (not interactive or
- pywikibot.input(
- u'Connecting %s -> %s. Proceed? [Y/N]'
- % (source.title(), dest.title())) in ['Y',
'y']):
+ pywikibot.input_yn(
+ u'Connecting %s -> %s. Proceed?'
+ % (source.title(), dest.title()),
+ default=False, automatic_quit=False)):
if self.getOption('side'):
# Placing {{Link FA|xx}} right next to
# corresponding interwiki
@@ -581,9 +582,10 @@
if m2:
if (changed or # Don't force the user to say "Y" twice
not interactive or
- pywikibot.input(
- u'Connecting %s -> %s. Proceed? [Y/N]'
- % (source.title(), dest.title())) in ['Y',
'y']):
+ pywikibot.input_yn(
+ u'Connecting %s -> %s. Proceed?'
+ % (source.title(), dest.title()),
+ default=False, automatic_quit=False)):
text = re.sub(re_Link_remove, '', text)
changed = True
elif task == 'former':
--
To view, visit
https://gerrit.wikimedia.org/r/169329
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I17fb04b9467acecffa98856668f4a92b81978509
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: jenkins-bot <>