From 4c6b1eb85f82536bfdcdee9cc7170a4a51cf5bf4 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 28 Jul 2016 15:51:42 +0530 Subject: added validation to check zip file --- yaksh/file_utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'yaksh') diff --git a/yaksh/file_utils.py b/yaksh/file_utils.py index 1e03f1f..8f6f6e5 100644 --- a/yaksh/file_utils.py +++ b/yaksh/file_utils.py @@ -13,7 +13,7 @@ def copy_files(file_paths): file_name = os.path.basename(file_path) files.append(file_name) shutil.copy(file_path, os.getcwd()) - if extract: + if extract and zipfile.is_zipfile(file_name): unzip = zipfile.ZipFile(file_name) for zip_files in unzip.namelist(): files.append(zip_files) @@ -25,9 +25,9 @@ def copy_files(file_paths): def delete_files(files): """ Delete Files from current directory """ - for content in files: - if os.path.exists(content): - if os.path.isfile(content): - os.remove(content) + for file in files: + if os.path.exists(file): + if os.path.isfile(file): + os.remove(file) else: - shutil.rmtree(content) + shutil.rmtree(file) -- cgit