jenkins-bot submitted this change.

View Change

Approvals: Matěj Suchánek: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
Clear unnecessary elifs & elses

Bug: T277891
Change-Id: Idb57995f3bdbfef8cfcb489ca92b819d0d2f4521
---
M pywikibot/site/_apisite.py
M pywikibot/specialbots/_upload.py
M scripts/archive/blockpageschecker.py
M scripts/archive/interwiki.py
M scripts/archive/makecat.py
M scripts/archive/nowcommons.py
M scripts/fixing_redirects.py
M scripts/pagefromfile.py
M scripts/redirect.py
M scripts/replace.py
M scripts/upload.py
M scripts/weblinkchecker.py
12 files changed, 34 insertions(+), 45 deletions(-)

diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 4832990..5b621eb 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -4574,8 +4574,7 @@
ignore_all_warnings = True
offset = data['offset']
continue
- else:
- return False
+ return False
result = data
result.setdefault('offset', 0)
break
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py
index f2f5329..149f13d 100644
--- a/pywikibot/specialbots/_upload.py
+++ b/pywikibot/specialbots/_upload.py
@@ -160,8 +160,7 @@
# {'Range': 'bytes=file_len-'}
if response.status_code == 416 and path.stat().st_size:
break
- else:
- raise FatalServerError(str(e)) from e
+ raise FatalServerError(str(e)) from e

if size and size == path.stat().st_size:
break
@@ -203,7 +202,7 @@
if this_answer is False:
answer = False
break
- elif this_answer is None:
+ if this_answer is None:
answer = None
if answer is None:
answer = pywikibot.input_yn('Do you want to ignore?',
@@ -296,8 +295,7 @@
automatic_quit=False)
if not overwrite:
continue
- else:
- break
+ break

pywikibot.output('File with name {} already exists and '
'cannot be overwritten.'.format(filename))
diff --git a/scripts/archive/blockpageschecker.py b/scripts/archive/blockpageschecker.py
index 033f1ad..d63b8fb 100755
--- a/scripts/archive/blockpageschecker.py
+++ b/scripts/archive/blockpageschecker.py
@@ -487,9 +487,8 @@
pywikibot.output('Server Error! Wait..')
time.sleep(3)
continue
- else:
- # Prevent Infinite Loops
- raise pywikibot.ServerError('Fifth Server Error!')
+ # Prevent Infinite Loops
+ raise pywikibot.ServerError('Fifth Server Error!')
except pywikibot.SpamblacklistError as e:
pywikibot.output('Cannot change %s because of '
'blacklist entry %s'
diff --git a/scripts/archive/interwiki.py b/scripts/archive/interwiki.py
index f6a7fb9..bd70ad0 100755
--- a/scripts/archive/interwiki.py
+++ b/scripts/archive/interwiki.py
@@ -1469,9 +1469,9 @@
if answer == 'a': # accept this one
result[site] = pages[0]
break
- elif answer == 'g': # give up
+ if answer == 'g': # give up
return None
- elif answer == 'r': # reject
+ if answer == 'r': # reject
# None acceptable
break
return result
diff --git a/scripts/archive/makecat.py b/scripts/archive/makecat.py
index f3d6182..9c948b4 100755
--- a/scripts/archive/makecat.py
+++ b/scripts/archive/makecat.py
@@ -214,10 +214,10 @@
break
self.include(pl)
break
- elif answer == 'n':
+ if answer == 'n':
excludefile.write('%s\n' % pl.title())
break
- elif answer == 'i':
+ if answer == 'i':
break
if answer in 'er':
self.treat_options = self.option_bar[answer]
diff --git a/scripts/archive/nowcommons.py b/scripts/archive/nowcommons.py
index 556ccd3..39bf2e8 100755
--- a/scripts/archive/nowcommons.py
+++ b/scripts/archive/nowcommons.py
@@ -317,11 +317,10 @@
else:
pywikibot.output('Please change them manually.')
continue
- else:
- pywikibot.output(color_format(
- 'No page is using "{lightgreen}{0}{default}" '
- 'anymore.',
- localImagePage.title(with_ns=False)))
+ pywikibot.output(color_format(
+ 'No page is using "{lightgreen}{0}{default}" '
+ 'anymore.',
+ localImagePage.title(with_ns=False)))
commonsText = commonsImagePage.get()
if self.opt.replaceonly is False:
if sha1 == commonsImagePage.latest_file_info.sha1:
diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py
index c4b5f9a..dc8e896 100755
--- a/scripts/fixing_redirects.py
+++ b/scripts/fixing_redirects.py
@@ -66,17 +66,15 @@
or mysite.isInterwikiLink(m.group('title'))
or isDisabled(text, m.start())):
continue
- else:
- actualLinkPage = pywikibot.Page(
- targetPage.site, m.group('title'))
- # Check whether the link found is to page.
- try:
- actualLinkPage.title()
- except InvalidTitle:
- pywikibot.exception()
- continue
- if actualLinkPage != linkedPage:
- continue
+ actualLinkPage = pywikibot.Page(targetPage.site, m.group('title'))
+ # Check whether the link found is to page.
+ try:
+ actualLinkPage.title()
+ except InvalidTitle:
+ pywikibot.exception()
+ continue
+ if actualLinkPage != linkedPage:
+ continue

# The link looks like this:
# [[page_title|link_text]]trailing_chars
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index 46a087c..a48868e 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -321,8 +321,7 @@
if _input == 'q':
failed_filename = True
break
- else:
- filename = _input
+ filename = _input

# show help text from the top of this file if reader failed
# or User quit.
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 4ce35fd..fa95c4f 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -596,13 +596,12 @@
'redirect-remove-loop')
self.delete_redirect(redir, 'redirect-remove-loop')
break
- else: # redirect target found
- if targetPage.isStaticRedirect():
- pywikibot.output(
- ' Redirect target is STATICREDIRECT.')
- else:
- newRedir = targetPage
- continue
+ # redirect target found
+ if targetPage.isStaticRedirect():
+ pywikibot.output(' Redirect target is STATICREDIRECT.')
+ else:
+ newRedir = targetPage
+ continue
oldText = redir.get(get_redirect=True)
if self.is_repo and redir.namespace() == self.repo.item_namespace:
redir = pywikibot.ItemPage(self.repo, redir.title())
diff --git a/scripts/replace.py b/scripts/replace.py
index ea0debb..b9ce176 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -596,7 +596,7 @@
if (replacement.container
and replacement.container.name in skipped_containers):
continue
- elif page is not None and self.isTitleExcepted(
+ if page is not None and self.isTitleExcepted(
page.title(), replacement.exceptions):
if replacement.container:
pywikibot.output(
diff --git a/scripts/upload.py b/scripts/upload.py
index ba07718..1a52578 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -178,8 +178,7 @@
if always:
url = None
break
- else:
- pywikibot.output(error)
+ pywikibot.output(error)
url = pywikibot.input('URL, file or directory where files are now:')

if always and (aborts is not True and ignorewarn is not True
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index ac9fb3b..9670077 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -494,9 +494,8 @@
if len(self.queue) == 0:
if self.finishing:
break
- else:
- time.sleep(0.1)
- continue
+ time.sleep(0.1)
+ continue

with self.semaphore:
url, errorReport, containingPage, archiveURL = self.queue[0]

To view, visit change 673692. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Idb57995f3bdbfef8cfcb489ca92b819d0d2f4521
Gerrit-Change-Number: 673692
Gerrit-PatchSet: 2
Gerrit-Owner: Homeboy 445 <akshitsan13@gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged