#334 Speed-up rules with caching for_app decorator
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from thefuck import shells
|
||||
import os
|
||||
import tarfile
|
||||
from thefuck import shells
|
||||
from thefuck.utils import for_app
|
||||
|
||||
|
||||
def _is_tar_extract(cmd):
|
||||
@@ -20,19 +21,19 @@ def _tar_file(cmd):
|
||||
for c in cmd.split():
|
||||
for ext in tar_extensions:
|
||||
if c.endswith(ext):
|
||||
return (c, c[0:len(c)-len(ext)])
|
||||
return (c, c[0:len(c) - len(ext)])
|
||||
|
||||
|
||||
@for_app('tar')
|
||||
def match(command, settings):
|
||||
return (command.script.startswith('tar')
|
||||
and '-C' not in command.script
|
||||
return ('-C' not in command.script
|
||||
and _is_tar_extract(command.script)
|
||||
and _tar_file(command.script) is not None)
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return shells.and_('mkdir -p {dir}', '{cmd} -C {dir}') \
|
||||
.format(dir=_tar_file(command.script)[1], cmd=command.script)
|
||||
.format(dir=_tar_file(command.script)[1], cmd=command.script)
|
||||
|
||||
|
||||
def side_effect(old_cmd, command, settings):
|
||||
|
||||
Reference in New Issue
Block a user