1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00

Cleanup pacman rule

This commit is contained in:
mcarton 2015-05-16 15:25:32 +02:00
parent d41b1d48d2
commit 5f2b2433b1

View File

@ -1,16 +1,5 @@
import subprocess
from thefuck.utils import DEVNULL
def __command_available(command):
try:
subprocess.check_output([command], stderr=DEVNULL)
return True
except subprocess.CalledProcessError:
# command exists but is not happy to be called without any argument
return True
except OSError:
return False
from thefuck.utils import DEVNULL, which
def __get_pkgfile(command):
@ -33,11 +22,11 @@ def get_new_command(command, settings):
return '{} -S {} && {}'.format(pacman, package, command.script)
if not __command_available('pkgfile'):
if not which('pkgfile'):
enabled_by_default = False
elif __command_available('yaourt'):
elif which('yaourt'):
pacman = 'yaourt'
elif __command_available('pacman'):
elif which('pacman'):
pacman = 'sudo pacman'
else:
enabled_by_default = False