-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutil.py
More file actions
31 lines (22 loc) · 950 Bytes
/
util.py
File metadata and controls
31 lines (22 loc) · 950 Bytes
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
import os
from datetime import datetime
import json
class Util:
def __init__(self):
self.__path = os.getcwd()
self.YEAR = datetime.now().year
self.MONTH = '%02d' % datetime.now().month
self.DAY = '%02d' % datetime.now().day
self.YEAR, self.MONTH, self.DAY = list(map(str, [self.YEAR, self.MONTH, self.DAY]))
def create_folder(self, ip) -> None:
try:
if not os.path.exists(self.get_path() + '\\' + str(ip)):
os.makedirs(self.get_path() + '\\' + str(ip))
except OSError:
print('Error : Creating directory')
def get_save_path(self, ip):
return self.get_pwd_path() + '\\' + self.YEAR + '\\' + self.MONTH + '\\' + self.DAY + '\\' + str(ip)
def get_path(self):
return self.get_pwd_path() + '\\' + self.YEAR + '\\' + self.MONTH + '\\' + self.DAY
def get_pwd_path(self):
return self.__path