jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[bugfix] Return gracefully from pwb.find_alternates if a folder does not exits

Bug: T308910
Change-Id: I452ecfd74145e2fc7beed56a5886555994995db2
---
M pwb.py
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/pwb.py b/pwb.py
index 3c46597..e7a35af 100755
--- a/pwb.py
+++ b/pwb.py
@@ -291,7 +291,7 @@

def find_alternates(filename, script_paths):
"""Search for similar filenames in the given script paths."""
- from pywikibot import config, input_choice, info
+ from pywikibot import config, input_choice, error, info, warning
from pywikibot.bot import QuitKeyboardInterrupt, ShowingListOption

assert config.pwb_close_matches > 0, \
@@ -299,14 +299,17 @@
assert 0.0 < config.pwb_cut_off < 1.0, \
'config.pwb_cut_off must be a float in range [0, 1]'

- print('ERROR: {} not found! Misspelling?'.format(filename),
- file=sys.stderr)
+ error('{} not found! Misspelling?'.format(filename))

scripts = {}

script_paths = [['.']] + script_paths # add current directory
for path in script_paths:
folder = Path(_pwb_dir).joinpath(*path)
+ if not folder.exists():
+ warning('{} does not exists; remove it from user_script_paths'
+ .format(folder))
+ continue
for script_name in folder.iterdir():
name, suffix = script_name.stem, script_name.suffix
if suffix == '.py' and not name.startswith('__'):

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I452ecfd74145e2fc7beed56a5886555994995db2
Gerrit-Change-Number: 794469
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged