1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-07-26 00:39:52 +01:00

Merge pull request from mcarton/fix-unzip

Fix the `dirty_unzip` rule
This commit is contained in:
Vladimir Iakovlev
2015-12-30 00:58:30 +03:00
2 changed files with 13 additions and 5 deletions

@@ -19,7 +19,6 @@ def _is_tar_extract(cmd):
def _tar_file(cmd): def _tar_file(cmd):
for c in cmd: for c in cmd:
for ext in tar_extensions: for ext in tar_extensions:
if c.endswith(ext): if c.endswith(ext):

@@ -5,8 +5,11 @@ from thefuck.shells import quote
def _is_bad_zip(file): def _is_bad_zip(file):
with zipfile.ZipFile(file, 'r') as archive: try:
return len(archive.namelist()) > 1 with zipfile.ZipFile(file, 'r') as archive:
return len(archive.namelist()) > 1
except:
return False
def _zip_file(command): def _zip_file(command):
@@ -24,8 +27,14 @@ def _zip_file(command):
@for_app('unzip') @for_app('unzip')
def match(command): def match(command):
return ('-d' not in command.script if '-d' in command.script:
and _is_bad_zip(_zip_file(command))) return False
zip_file = _zip_file(command)
if zip_file:
return _is_bad_zip(zip_file)
else:
return False
def get_new_command(command): def get_new_command(command):