mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
#786: Fix apt_get rule on ubuntu 18.04
This commit is contained in:
parent
ed24e4ca61
commit
fb39d0bbd3
@ -1,3 +1,4 @@
|
||||
from types import ModuleType
|
||||
from thefuck.specific.apt import apt_available
|
||||
from thefuck.utils import memoize, which
|
||||
from thefuck.shells import shell
|
||||
@ -5,8 +6,14 @@ from thefuck.shells import shell
|
||||
try:
|
||||
from CommandNotFound import CommandNotFound
|
||||
|
||||
command_not_found = CommandNotFound()
|
||||
enabled_by_default = apt_available
|
||||
|
||||
if isinstance(CommandNotFound, ModuleType):
|
||||
# For ubuntu 18.04+
|
||||
_get_packages = CommandNotFound.CommandNotFound().get_packages
|
||||
else:
|
||||
# For older versions
|
||||
_get_packages = CommandNotFound().getPackages
|
||||
except ImportError:
|
||||
enabled_by_default = False
|
||||
|
||||
@ -21,7 +28,7 @@ def _get_executable(command):
|
||||
@memoize
|
||||
def get_package(executable):
|
||||
try:
|
||||
packages = command_not_found.getPackages(executable)
|
||||
packages = _get_packages(executable)
|
||||
return packages[0][0]
|
||||
except IndexError:
|
||||
# IndexError is thrown when no matching package is found
|
||||
|
Loading…
x
Reference in New Issue
Block a user