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.specific.apt import apt_available
|
||||||
from thefuck.utils import memoize, which
|
from thefuck.utils import memoize, which
|
||||||
from thefuck.shells import shell
|
from thefuck.shells import shell
|
||||||
@ -5,8 +6,14 @@ from thefuck.shells import shell
|
|||||||
try:
|
try:
|
||||||
from CommandNotFound import CommandNotFound
|
from CommandNotFound import CommandNotFound
|
||||||
|
|
||||||
command_not_found = CommandNotFound()
|
|
||||||
enabled_by_default = apt_available
|
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:
|
except ImportError:
|
||||||
enabled_by_default = False
|
enabled_by_default = False
|
||||||
|
|
||||||
@ -21,7 +28,7 @@ def _get_executable(command):
|
|||||||
@memoize
|
@memoize
|
||||||
def get_package(executable):
|
def get_package(executable):
|
||||||
try:
|
try:
|
||||||
packages = command_not_found.getPackages(executable)
|
packages = _get_packages(executable)
|
||||||
return packages[0][0]
|
return packages[0][0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# IndexError is thrown when no matching package is found
|
# IndexError is thrown when no matching package is found
|
||||||
|
Loading…
x
Reference in New Issue
Block a user