summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authoradityacp2016-07-11 16:43:35 +0530
committeradityacp2016-07-28 15:56:06 +0530
commit21f53d77a83ce683ad64b2031cd2b8b7aba05c26 (patch)
tree02d144ea9aad99b40f6cccaa5601c6b375e2c0ed /yaksh
parent80453af850b5080a43eb309b50151ecc8e5f6578 (diff)
downloadonline_test-21f53d77a83ce683ad64b2031cd2b8b7aba05c26.tar.gz
online_test-21f53d77a83ce683ad64b2031cd2b8b7aba05c26.tar.bz2
online_test-21f53d77a83ce683ad64b2031cd2b8b7aba05c26.zip
changed module name from copy_delete_files to file_utils
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/file_utils.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/yaksh/file_utils.py b/yaksh/file_utils.py
new file mode 100644
index 0000000..1e03f1f
--- /dev/null
+++ b/yaksh/file_utils.py
@@ -0,0 +1,33 @@
+import shutil
+import os
+import zipfile
+
+
+def copy_files(file_paths):
+ """ Copy Files to current directory, takes
+ tuple with file paths and extract status"""
+
+ files = []
+ for src in file_paths:
+ file_path, extract = src
+ file_name = os.path.basename(file_path)
+ files.append(file_name)
+ shutil.copy(file_path, os.getcwd())
+ if extract:
+ unzip = zipfile.ZipFile(file_name)
+ for zip_files in unzip.namelist():
+ files.append(zip_files)
+ unzip.extractall()
+ unzip.close()
+ return files
+
+
+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)
+ else:
+ shutil.rmtree(content)