jenkins-bot submitted this change.
[IMPR] Shorten the loop in add_text.py
- if putText is not True add_text function may return earlier
- in result the next if statement needs only to check whether
text != newtext
- the while loop is only needed for 'b'rowser choice, so shorten
the loop here too.
Change-Id: Ie5002dec8e23b15a78c8f6fd7b9351e3cfe0c09d
---
M scripts/add_text.py
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/scripts/add_text.py b/scripts/add_text.py
index 43e80c3..7481198 100755
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -248,7 +248,12 @@
else:
newtext = addText + '\n' + text
- if putText and text != newtext:
+ if not putText:
+ # If someone load it as module, maybe it's not so useful to put the
+ # text in the page
+ return (text, newtext, always)
+
+ if text != newtext:
pywikibot.output(color_format(
'\n\n>>> {lightpurple}{0}{default} <<<', page.title()))
pywikibot.showDiff(text, newtext)
@@ -256,11 +261,6 @@
# Let's put the changes.
error_count = 0
while True:
- # If someone load it as module, maybe it's not so useful to put the
- # text in the page
- if not putText:
- return (text, newtext, always)
-
if not always:
try:
choice = pywikibot.input_choice(
@@ -276,13 +276,14 @@
return (False, False, always)
elif choice == 'b':
pywikibot.bot.open_webbrowser(page)
+ continue
- if always or choice == 'y':
- result = put_text(page, newtext, summary, error_count,
- asynchronous=not always)
- if result is not None:
- return (result, result, always)
- error_count += 1
+ # either always or choice == 'y' is selected
+ result = put_text(page, newtext, summary, error_count,
+ asynchronous=not always)
+ if result is not None:
+ return (result, result, always)
+ error_count += 1
def main(*args):
To view, visit change 587635. To unsubscribe, or for help writing mail filters, visit settings.