forked from MarieTzschaschel/VA2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimeLabelDataSetModule.py
41 lines (31 loc) · 1.14 KB
/
TimeLabelDataSetModule.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
37
38
#from sets import Set
from TimeLabelDataModule import TimeLabelData
from TimeLabelDataModule import printList
import os
import pickle
import datetime
#item_collection = Set()
class TimeLabelDataSet:
def __init__(self):
self.dataSets = []
def importFromFile(self,file):
if os.path.exists(file):
with open(file,'rb') as handle:
self.dataSets = pickle.load(handle)
def saveToFile(self):
DEST_FOLDER_PATH = os.path.dirname(os.path.abspath(__file__)) +"\\"+str(datetime.date.today())
now = datetime.datetime.now()
curtime = str(now.hour) +"-"+ str(now.minute)
if not os.path.isdir(DEST_FOLDER_PATH):
os.mkdir(DEST_FOLDER_PATH)
with open(DEST_FOLDER_PATH + "\\"+ curtime ,"wb") as handle:
pickle.dump(self.dataSets, handle)
def addTimeLabelData(self, *args):
for arg in args:
if type(arg).__name__ == "TimeLabelData" :
self.dataSets.append(arg)
def printData(self):
for TimeLabelData in self.dataSets:
TimeLabelData.printData()
def printNames(self):
printList([TimeLabelData.name for TimeLabelData in self.dataSets])