diff options
author | adityacp | 2016-07-28 15:51:42 +0530 |
---|---|---|
committer | adityacp | 2016-07-28 15:56:06 +0530 |
commit | 4c6b1eb85f82536bfdcdee9cc7170a4a51cf5bf4 (patch) | |
tree | e64dea7607580f3c0b1a7b3a1eb4cc8311a1e94d /yaksh/file_utils.py | |
parent | 7befccf9e3cd6abf1b4d5a24e9af9688ba5f50b4 (diff) | |
download | online_test-4c6b1eb85f82536bfdcdee9cc7170a4a51cf5bf4.tar.gz online_test-4c6b1eb85f82536bfdcdee9cc7170a4a51cf5bf4.tar.bz2 online_test-4c6b1eb85f82536bfdcdee9cc7170a4a51cf5bf4.zip |
added validation to check zip file
Diffstat (limited to 'yaksh/file_utils.py')
-rw-r--r-- | yaksh/file_utils.py | 12 |
1 files changed, 6 insertions, 6 deletions
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) |