-
Notifications
You must be signed in to change notification settings - Fork 0
/
Directory.py
36 lines (26 loc) · 1 KB
/
Directory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import shutil
class Directory(object):
""" A Directory will have path and name with following properties:
Attributes:
dir_name: A string representing the directory name.
dir_path: path where the directory will be created.
"""
def __init__(self, dir_name, dir_path=os.getcwd()):
self.dir_name = dir_name
self.dir_path = os.path.join(dir_path, self.dir_name)
self.create_directory(self.dir_path)
@staticmethod
def create_directory(dir_path):
if not os.path.exists(dir_path):
os.makedirs(dir_path)
def set_path(self, dir_path):
self.dir_path = os.path.join(dir_path, self.dir_name)
def get_path(self):
return self.dir_path
def set_dir_name(self, dir_name):
self.dir_name = dir_name
def get_dir_name(self):
return self.dir_name
def make_archive(self):
shutil.make_archive(self.get_path(), 'zip', root_dir=self.get_path())