jenkins-bot has submitted this change and it was merged. Change subject: Improvements for pwb.py: ......................................................................
Improvements for pwb.py: - always add ".py" suffix if omitted. This enables running scripts outside the /scripts folder, e.g. library test functions as main module - raise OSError when the given script name does not exist because "file not found" error is an OSError (in py3 which merged IOError to that) Change-Id: Ie58e9573214accd013a8688816254173df1a5c33 --- M pwb.py 1 file changed, 3 insertions(+), 6 deletions(-) Approvals: Ladsgroup: Looks good to me, approved jenkins-bot: Verified diff --git a/pwb.py b/pwb.py index 945d4e1..ae9190a 100644 --- a/pwb.py +++ b/pwb.py @@ -109,17 +109,14 @@ fn = sys.argv[1] argv = sys.argv[1:] argvu = pwb.argvu[1:] - + if not fn.endswith('.py'): + fn += '.py' if not os.path.exists(fn): testpath = os.path.join(os.path.split(__file__)[0], 'scripts', fn) if os.path.exists(testpath): fn = testpath else: - testpath = testpath + '.py' - if os.path.exists(testpath): - fn = testpath - else: - raise Exception("%s not found!" % fn) + raise OSError("%s not found!" % fn) run_python_file(fn, argv, argvu) elif __name__ == "__main__": print(__doc__) -- To view, visit https://gerrit.wikimedia.org/r/98538 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie58e9573214accd013a8688816254173df1a5c33 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: Xqt <i...@gno.de> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits