#71 Not fail on os error

This commit is contained in:
nvbn
2015-04-21 08:30:48 +02:00
parent 273fc097bd
commit 478fa4cd09
2 changed files with 10 additions and 3 deletions
+9 -2
View File
@@ -3,11 +3,18 @@ import os
from pathlib import Path
def _safe(path, method):
try:
return getattr(path, method)()
except OSError:
return []
def _get_all_bins():
return [exe.name
for path in os.environ['PATH'].split(':')
for exe in Path(path).iterdir()
if exe.is_file()]
for exe in _safe(Path(path), 'iterdir')
if not _safe(exe, 'is_dir')]
def match(command, settings):