jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/794469 )
Change subject: [bugfix] Return gracefully from pwb.find_alternates if a folder does not exits ......................................................................
[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(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
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('__'):
pywikibot-commits@lists.wikimedia.org