Kaydet (Commit) 0ba7e595 authored tarafından Guido van Rossum's avatar Guido van Rossum

More rational implementation of get_qualified_path() -- search along

sys.path instead of assuming __file__ works.
üst e61093c2
...@@ -152,20 +152,13 @@ def getimage(name): ...@@ -152,20 +152,13 @@ def getimage(name):
return (image, sizes[0], sizes[1]) return (image, sizes[0], sizes[1])
def get_qualified_path(name): 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 sys
import os import os
import string for dir in sys.path:
fullname = os.path.join(dir, name)
# get a more qualified path component of the script... if os.path.exists(fullname):
if __name__ == '__main__': return fullname
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)
return name return name
# rgbimg (unlike imgfile) is portable to platforms other than SGI. # rgbimg (unlike imgfile) is portable to platforms other than SGI.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment