def find_on_path(importer, path_item, only=False):
path_item = _normalize_cached(path_item)<EOL>if os.path.isdir(path_item) and os.access(path_item, os.R_OK):<EOL><INDENT>if path_item.lower().endswith('<STR_LIT>'):<EOL><INDENT>yield Distribution.from_filename(<EOL>path_item, metadata=PathMetadata(<EOL>path_item, os.path.join(path_item,'<STR_LIT>')<EOL>)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>for entry in os.listdir(path_item):<EOL><INDENT>lower = entry.lower()<EOL>if lower.endswith('<STR_LIT>') or lower.endswith('<STR_LIT>'):<EOL><INDENT>fullpath = os.path.join(path_item, entry)<EOL>if os.path.isdir(fullpath):<EOL><INDENT>metadata = PathMetadata(path_item, fullpath)<EOL><DEDENT>else:<EOL><INDENT>metadata = FileMetadata(fullpath)<EOL><DEDENT>yield Distribution.from_location(<EOL>path_item,entry,metadata,precedence=DEVELOP_DIST<EOL>)<EOL><DEDENT>elif not only and lower.endswith('<STR_LIT>'):<EOL><INDENT>for dist in find_distributions(os.path.join(path_item, entry)):<EOL><INDENT>yield dist<EOL><DEDENT><DEDENT>elif not only and lower.endswith('<STR_LIT>'):<EOL><INDENT>for line in open(os.path.join(path_item, entry)):<EOL><INDENT>if not line.strip(): continue<EOL>for item in find_distributions(os.path.join(path_item,line.rstrip())):<EOL><INDENT>yield item<EOL><DEDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>
Yield distributions accessible on a sys.path directory