mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 09:39:01 +00:00
Really fix the tests
This commit is contained in:
parent
08bc90903f
commit
8b70fef5b6
@ -76,7 +76,7 @@ apt_get_operations = ['update', 'upgrade', 'install', 'remove', 'autoremove',
|
|||||||
'dselect-upgrade', 'clean', 'autoclean', 'check',
|
'dselect-upgrade', 'clean', 'autoclean', 'check',
|
||||||
'changelog', 'download']
|
'changelog', 'download']
|
||||||
|
|
||||||
new_apt_get_help = '''apt 1.6.12 (amd64)
|
new_apt_get_help = b'''apt 1.6.12 (amd64)
|
||||||
Usage: apt-get [options] command
|
Usage: apt-get [options] command
|
||||||
apt-get [options] install|remove pkg1 [pkg2 ...]
|
apt-get [options] install|remove pkg1 [pkg2 ...]
|
||||||
apt-get [options] source pkg1 [pkg2 ...]
|
apt-get [options] source pkg1 [pkg2 ...]
|
||||||
|
@ -6,8 +6,8 @@ from thefuck.utils import for_app, eager, replace_command
|
|||||||
enabled_by_default = apt_available
|
enabled_by_default = apt_available
|
||||||
|
|
||||||
|
|
||||||
@for_app('apt', 'apt-get', 'apt-cache')
|
|
||||||
@sudo_support
|
@sudo_support
|
||||||
|
@for_app('apt', 'apt-get', 'apt-cache')
|
||||||
def match(command):
|
def match(command):
|
||||||
return 'E: Invalid operation' in command.output
|
return 'E: Invalid operation' in command.output
|
||||||
|
|
||||||
@ -20,8 +20,22 @@ def _parse_apt_operations(help_text_lines):
|
|||||||
if is_commands_list and line:
|
if is_commands_list and line:
|
||||||
yield line.split()[0]
|
yield line.split()[0]
|
||||||
elif line.startswith('Basic commands:') \
|
elif line.startswith('Basic commands:') \
|
||||||
or line.startswith('Most used commands:') \
|
or line.startswith('Most used commands:'):
|
||||||
or line.startswith('Commands:'):
|
is_commands_list = True
|
||||||
|
|
||||||
|
|
||||||
|
@eager
|
||||||
|
def _parse_apt_get_and_cache_operations(help_text_lines):
|
||||||
|
is_commands_list = False
|
||||||
|
for line in help_text_lines:
|
||||||
|
line = line.decode().strip()
|
||||||
|
if is_commands_list:
|
||||||
|
if not line:
|
||||||
|
return
|
||||||
|
|
||||||
|
yield line.split()[0]
|
||||||
|
elif line.startswith('Commands:') \
|
||||||
|
or line.startswith('Most used commands:'):
|
||||||
is_commands_list = True
|
is_commands_list = True
|
||||||
|
|
||||||
|
|
||||||
@ -31,11 +45,19 @@ def _get_operations(app):
|
|||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
lines = proc.stdout.readlines()
|
lines = proc.stdout.readlines()
|
||||||
|
|
||||||
|
if app == 'apt':
|
||||||
return _parse_apt_operations(lines)
|
return _parse_apt_operations(lines)
|
||||||
|
else:
|
||||||
|
return _parse_apt_get_and_cache_operations(lines)
|
||||||
|
|
||||||
|
|
||||||
@sudo_support
|
@sudo_support
|
||||||
def get_new_command(command):
|
def get_new_command(command):
|
||||||
invalid_operation = command.output.split()[-1]
|
invalid_operation = command.output.split()[-1]
|
||||||
|
|
||||||
|
if invalid_operation == 'uninstall':
|
||||||
|
return [command.script.replace('uninstall', 'remove')]
|
||||||
|
|
||||||
|
else:
|
||||||
operations = _get_operations(command.script_parts[0])
|
operations = _get_operations(command.script_parts[0])
|
||||||
return replace_command(command, invalid_operation, operations)
|
return replace_command(command, invalid_operation, operations)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user