summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-05-14 18:57:21 (GMT)
committerGuido van Rossum <guido@python.org>1997-05-14 18:57:21 (GMT)
commit0ba7e5958cbd7de85ab09620714f1e77f99bef67 (patch)
tree8490b9f1b088e7a8fb3e0931256b0f2db86e8dae /Lib
parente61093c2187472c5761e7c282aa579c37967018e (diff)
downloadcpython-0ba7e5958cbd7de85ab09620714f1e77f99bef67.zip
cpython-0ba7e5958cbd7de85ab09620714f1e77f99bef67.tar.gz
cpython-0ba7e5958cbd7de85ab09620714f1e77f99bef67.tar.bz2
More rational implementation of get_qualified_path() -- search along
sys.path instead of assuming __file__ works.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/test_imageop.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/Lib/test/test_imageop.py b/Lib/test/test_imageop.py
index f9108ef..77281ab 100755
--- a/Lib/test/test_imageop.py
+++ b/Lib/test/test_imageop.py
@@ -152,20 +152,13 @@ def getimage(name):
return (image, sizes[0], sizes[1])
def get_qualified_path(name):
- """ return a more qualified path to name contructed from argv[1]"""
+ """ return a more qualified path to name"""
import sys
import os
- import string
-
- # get a more qualified path component of the script...
- if __name__ == '__main__':
- ourname = sys.argv[0]
- else: # ...or the full path of the module
- ourname = sys.modules[__name__].__file__
-
- parts = string.splitfields(ourname, os.sep)
- parts[-1] = name
- name = string.joinfields(parts, os.sep)
+ for dir in sys.path:
+ fullname = os.path.join(dir, name)
+ if os.path.exists(fullname):
+ return fullname
return name
# rgbimg (unlike imgfile) is portable to platforms other than SGI.