Xqt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/98538


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/38/98538/1

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: newchange
Gerrit-Change-Id: Ie58e9573214accd013a8688816254173df1a5c33
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to