Create thefuck.archlinux

This commit is contained in:
mcarton
2015-08-12 17:13:32 +02:00
parent 0ad70a1edc
commit 986bbb30a7
4 changed files with 50 additions and 37 deletions
+4 -34
View File
@@ -1,46 +1,16 @@
import subprocess
from thefuck.utils import DEVNULL, which
from thefuck.archlinux import archlinux_env, get_pkgfile
from thefuck import shells
from thefuck.utils import memoize
@memoize
def __get_pkgfile(command):
try:
command = command.script
if command.startswith('sudo'):
command = command[5:]
command = command.split(" ")[0]
packages = subprocess.check_output(
['pkgfile', '-b', '-v', command],
universal_newlines=True, stderr=DEVNULL
).splitlines()
return [package.split()[0] for package in packages]
except subprocess.CalledProcessError:
return None
def match(command, settings):
return 'not found' in command.stderr and __get_pkgfile(command)
return 'not found' in command.stderr and get_pkgfile(command)
def get_new_command(command, settings):
packages = __get_pkgfile(command)
packages = get_pkgfile(command)
formatme = shells.and_('{} -S {}', '{}')
return [formatme.format(pacman, package, command.script)
for package in packages]
if not which('pkgfile'):
enabled_by_default = False
elif which('yaourt'):
pacman = 'yaourt'
elif which('pacman'):
pacman = 'sudo pacman'
else:
enabled_by_default = False
enabled_by_default, pacman = archlinux_env()