in cstar/command.py [0:0]
def _list(listdir, stat, check_is_file):
"""Returns a list of the names of all available commands"""
res = {}
for dir in _search_path():
try:
for filename in listdir(dir):
full_name = os.path.join(dir, filename)
try:
if not check_is_file(stat(full_name)):
continue
except FileNotFoundError:
continue
if filename.endswith("~") or filename.startswith("#"):
continue
if "." in filename:
prefix = re.sub(r"\..*", "", filename)
else:
prefix = filename
if prefix not in res:
res[prefix] = full_name
except FileNotFoundError:
pass
return res