def find_on_path(importer, path_item, only=False):
 path_item = _normalize_cached(path_item)
 if os.path.isdir(path_item):
  if path_item.lower().endswith('.egg'):
   (yield Distribution.from_filename(path_item, metadata=PathMetadata(path_item, os.path.join(path_item, 'EGG-INFO'))))
  else:
   for entry in os.listdir(path_item):
    lower = entry.lower()
    if lower.endswith('.egg-info'):
     fullpath = os.path.join(path_item, entry)
     if os.path.isdir(fullpath):
      metadata = PathMetadata(path_item, fullpath)
     else:
      metadata = FileMetadata(fullpath)
     (yield Distribution.from_location(path_item, entry, metadata, precedence=DEVELOP_DIST))
    elif ((not only) and lower.endswith('.egg')):
     for dist in find_distributions(os.path.join(path_item, entry)):
      (yield dist)
    elif ((not only) and lower.endswith('.egg-link')):
     for line in file(os.path.join(path_item, entry)):
      if (not line.strip()):
       continue
      for item in find_distributions(os.path.join(path_item, line.rstrip())):
       (yield item)
      break

def find_on_path ( importer , path_item , only = False ) : path_item = _normalize_cached ( path_item ) if os . path . isdir ( path_item ) : if path_item . lower ( ) . endswith ( '.egg' ) : ( yield Distribution . from_filename ( path_item , metadata = PathMetadata ( path_item , os . path . join ( path_item , 'EGG-INFO' ) ) ) ) else : for entry in os . listdir ( path_item ) : lower = entry . lower ( ) if lower . endswith ( '.egg-info' ) : fullpath = os . path . join ( path_item , entry ) if os . path . isdir ( fullpath ) : metadata = PathMetadata ( path_item , fullpath ) else : metadata = FileMetadata ( fullpath ) ( yield Distribution . from_location ( path_item , entry , metadata , precedence = DEVELOP_DIST ) ) elif ( ( not only ) and lower . endswith ( '.egg' ) ) : for dist in find_distributions ( os . path . join ( path_item , entry ) ) : ( yield dist ) elif ( ( not only ) and lower . endswith ( '.egg-link' ) ) : for line in file ( os . path . join ( path_item , entry ) ) : if ( not line . strip ( ) ) : continue for item in find_distributions ( os . path . join ( path_item , line . rstrip ( ) ) ) : ( yield item ) break
search the path for a program and return full path .