summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2016-06-20 14:59:56 +0530
committeradityacp2016-07-28 15:56:06 +0530
commit8796936bc739e8da694a02286f440796e6d5ead6 (patch)
tree365e64562bd9c52e0e03c51269ca776978a8ed72
parent1785d2613b8a56b0204c257b31e721be7032515a (diff)
downloadonline_test-8796936bc739e8da694a02286f440796e6d5ead6.tar.gz
online_test-8796936bc739e8da694a02286f440796e6d5ead6.tar.bz2
online_test-8796936bc739e8da694a02286f440796e6d5ead6.zip
created file copier to copy files
-rw-r--r--yaksh/copy_delete_files.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/yaksh/copy_delete_files.py b/yaksh/copy_delete_files.py
new file mode 100644
index 0000000..f34b944
--- /dev/null
+++ b/yaksh/copy_delete_files.py
@@ -0,0 +1,29 @@
+import shutil
+import os
+import zipfile
+
+
+class CopyDeleteFiles(object):
+
+ def copy_files(self, file_paths):
+ 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(self, files):
+ for content in files:
+ if os.path.exists(content):
+ if os.path.isfile(content):
+ os.remove(content)
+ else:
+ shutil.rmtree(content)