Changeset 2664


Ignore:
Timestamp:
11/21/11 12:19:41 (2 years ago)
Author:
jdsiiro
Message:

Simplifying search_file() to remove redundant logic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyutilib.misc/trunk/pyutilib/misc/misc.py

    r2662 r2664  
    233233            search_path = os.defpath.split(os.pathsep) 
    234234    for path in search_path: 
    235         if os.path.exists(os.path.join(path, filename)) and \ 
    236            (not isfile or os.path.isfile(os.path.join(path, filename))): 
    237             if not executable or os.access(os.path.join(path,filename),os.X_OK): 
    238                 file = os.path.abspath(os.path.join(path, filename)) 
    239                 if validate is None or validate(file): 
    240                     return file 
    241         if os.path.exists(os.path.join(path, filename+implicitExt)) and \ 
    242            (not isfile or os.path.isfile(os.path.join(path, filename+implicitExt))): 
    243             if not executable or os.access(os.path.join(path,filename+implicitExt),os.X_OK): 
    244                 file = os.path.abspath(os.path.join(path, filename+implicitExt)) 
     235        for ext in ('', implicitExt): 
     236            test_fname = os.path.join(path, filename+ext) 
     237            if os.path.exists(test_fname) \ 
     238                   and (not isfile or os.path.isfile(test_fname)) \ 
     239                   and (not executable or os.access(test_fname, os.X_OK)): 
     240                file = os.path.abspath(test_fname) 
    245241                if validate is None or validate(file): 
    246242                    return file 
Note: See TracChangeset for help on using the changeset viewer.