Beispiel #1
0
    def delete(anIndex):
        if (RelativeProjectPathManager.isThereFile(Group.FILE_PATH_TO_SAVE)):
            groups = Group.all()
            for groupTuple in enumerate(groups):
                if (groupTuple[1].id == anIndex):
                    groups.pop(groupTuple[0])

            os.remove(
                RelativeProjectPathManager.getRealFilePathToSave(
                    Group.FILE_PATH_TO_SAVE))
            with open(RelativeProjectPathManager.getRealFilePathToSave(
                    Group.FILE_PATH_TO_SAVE),
                      'w',
                      encoding='UTF8') as wCSVFile:
                writer = csv.writer(wCSVFile, delimiter=',')
                for group in groups:
                    row = []
                    row.append(group.id)
                    row.append(
                        TimeFormatter.toDatetimeString(group.period.start))
                    row.append(TimeFormatter.toDatetimeString(
                        group.period.end))
                    row.append(group.nickName)
                    row.append(
                        TimeFormatter.toDatetimeString(group.savedDateTime))
                    writer.writerow(row)
                    wCSVFile.close()
 def all():
     result = []
     if(RelativeProjectPathManager.isThereFile(Group.FILE_PATH_TO_SAVE)):
         with open(RelativeProjectPathManager.getRealFilePathToSave(Group.FILE_PATH_TO_SAVE), 'r', encoding='UTF8') as rCSVFile:
             reader = csv.reader(rCSVFile, delimiter=',')
             for row in reader:
                 result.append(Group.fromCSVRow(aRow=row))
     return result
Beispiel #3
0
 def all():
     result = []
     if (RelativeProjectPathManager.isThereFile(Group.FILE_PATH_TO_SAVE)):
         with open(RelativeProjectPathManager.getRealFilePathToSave(
                 Group.FILE_PATH_TO_SAVE),
                   'r',
                   encoding='UTF8') as rCSVFile:
             reader = csv.reader(rCSVFile, delimiter=',')
             for row in reader:
                 result.append(Group.fromCSVRow(aRow=row))
     return result
 def findById(anId):
     result = None
     if(RelativeProjectPathManager.isThereFile(Group.FILE_PATH_TO_SAVE)):
         with open(RelativeProjectPathManager.getRealFilePathToSave(Group.FILE_PATH_TO_SAVE), 'r', encoding='UTF8') as rCSVFile:
             reader = csv.reader(rCSVFile, delimiter=',')
             for row in reader:
                 group = Group.fromCSVRow(row)
                 if(group.id == anId):
                     result = group
                     break
             rCSVFile.close()
     return result
Beispiel #5
0
 def findById(anId):
     result = None
     if (RelativeProjectPathManager.isThereFile(Group.FILE_PATH_TO_SAVE)):
         with open(RelativeProjectPathManager.getRealFilePathToSave(
                 Group.FILE_PATH_TO_SAVE),
                   'r',
                   encoding='UTF8') as rCSVFile:
             reader = csv.reader(rCSVFile, delimiter=',')
             for row in reader:
                 group = Group.fromCSVRow(row)
                 if (group.id == anId):
                     result = group
                     break
             rCSVFile.close()
     return result
def saveUserLog(aSessionId, aFileName):
    with open(
            RelativeProjectPathManager.getRealFilePathToSave(
                directoryPathToSave + '/' + aFileName), 'w') as wFile:
        wFile.write(
            json.dumps((ClassweekHttpRequester.getAPICallLogListGivenSessionId(
                aSessionId, captureDatetime))))
    def delete(anIndex):
        if(RelativeProjectPathManager.isThereFile(Group.FILE_PATH_TO_SAVE)):
            groups = Group.all()
            for groupTuple in enumerate(groups):
                if(groupTuple[1].id == anIndex):
                    groups.pop(groupTuple[0])

            os.remove(RelativeProjectPathManager.getRealFilePathToSave(Group.FILE_PATH_TO_SAVE))
            with open(RelativeProjectPathManager.getRealFilePathToSave(Group.FILE_PATH_TO_SAVE), 'w', encoding='UTF8') as wCSVFile:
                writer = csv.writer(wCSVFile, delimiter=',')
                for group in groups:
                    row = []
                    row.append(group.id)
                    row.append(TimeFormatter.toDatetimeString(group.period.start))
                    row.append(TimeFormatter.toDatetimeString(group.period.end))
                    row.append(group.nickName)
                    row.append(TimeFormatter.toDatetimeString(group.savedDateTime))
                    writer.writerow(row)
                    wCSVFile.close()
    def save(self):
        if(Group.findById(self.id) is not None):
            Group.delete(self.id)

        with open(RelativeProjectPathManager.getRealFilePathToSave(Group.FILE_PATH_TO_SAVE), 'a', encoding='UTF8') as wCSVFile:
            writer = csv.writer(wCSVFile, delimiter=',')
            row = []
            row.append(self.id)
            row.append(TimeFormatter.toDatetimeString(self.period.start))
            row.append(TimeFormatter.toDatetimeString(self.period.end))
            row.append(self.nickName)
            self.savedDateTime = datetime.now()
            row.append(TimeFormatter.toDatetimeString(self.savedDateTime))
            writer.writerow(row)
            wCSVFile.close()
Beispiel #9
0
    def save(self):
        if (Group.findById(self.id) is not None):
            Group.delete(self.id)

        with open(RelativeProjectPathManager.getRealFilePathToSave(
                Group.FILE_PATH_TO_SAVE),
                  'a',
                  encoding='UTF8') as wCSVFile:
            writer = csv.writer(wCSVFile, delimiter=',')
            row = []
            row.append(self.id)
            row.append(TimeFormatter.toDatetimeString(self.period.start))
            row.append(TimeFormatter.toDatetimeString(self.period.end))
            row.append(self.nickName)
            self.savedDateTime = datetime.now()
            row.append(TimeFormatter.toDatetimeString(self.savedDateTime))
            writer.writerow(row)
            wCSVFile.close()
Beispiel #10
0
 def setUp(self):
     try:
         os.remove(
             RelativeProjectPathManager.getRealFilePathToSave(
                 Group.FILE_PATH_TO_SAVE))
     except:
         pass
     Group.FILE_PATH_TO_SAVE = GroupTest.directoryPathToSave
     self.groups = []
     self.groups.append(
         Group(anId=1,
               aStartDate=TimeFormatter.toDatetime('2014-06-01 00:00:00'),
               anEndDate=TimeFormatter.toDatetime('2014-06-01 23:59:59'),
               aNickname="5월 4째주"))
     self.groups.append(
         Group(anId=2,
               aStartDate=TimeFormatter.toDatetime('2011-09-09 00:00:00'),
               anEndDate=TimeFormatter.toDatetime('2013-12-12 23:59:59'),
               aNickname="ㅋㅋㅋ"))
Beispiel #11
0
 def testDetermineUserTypeAsCurios(self):
     with open(RelativeProjectPathManager.getRealFilePathToSave( UserBehaviorTest.directoryPathToSave + '/'+'curiosUserLog'),'r') as rFile:
         self.assertEqual(UserBehavior('09FN8+0qQscHPgeR5RrTmg==',json.loads(rFile.read())).type, UserBehavior.TYPE_CURIOUS)
Beispiel #12
0
 def testDetermineUserTypeAsFilter(self):
     with open(RelativeProjectPathManager.getRealFilePathToSave( UserBehaviorTest.directoryPathToSave + '/'+'filterUserLog'),'r') as rFile:
         self.assertEqual(UserBehavior('c5vZhTq3BBgQeRS+S4MZFA==',json.loads(rFile.read())).type, UserBehavior.TYPE_FILTER)
Beispiel #13
0
 def testDetermineUserTypeAsIndifference(self):
     with open(RelativeProjectPathManager.getRealFilePathToSave( UserBehaviorTest.directoryPathToSave + '/'+'indifferenceUserLog'),'r') as rFile:
         self.assertEqual(UserBehavior('/2rzhbp7QK6j5ZeaNJ91Vw==',json.loads(rFile.read())).type, UserBehavior.TYPE_INDIFFERENCE)
Beispiel #14
0
 def testDetermineUserTypeAsInterested(self):
     with open(RelativeProjectPathManager.getRealFilePathToSave( UserBehaviorTest.directoryPathToSave + '/'+'interestedUserLog'),'r') as rFile:
         self.assertEqual(UserBehavior('u36ZPhbKkBuucfTgrRv0RQ==',json.loads(rFile.read())).type, UserBehavior.TYPE_INTERESTED)
Beispiel #15
0
 def testDetermineUserTypeAsPayment(self):
     with open(RelativeProjectPathManager.getRealFilePathToSave( UserBehaviorTest.directoryPathToSave + '/'+'paymentUserLog'),'r') as rFile:
         self.assertEqual(UserBehavior('6xCPnJszbCVLRq5BckcXfQ==',json.loads(rFile.read())).type, UserBehavior.TYPE_PAYMENT)
def saveUserLog(aSessionId, aFileName):
    with open(RelativeProjectPathManager.getRealFilePathToSave( directoryPathToSave + '/'+aFileName),'w') as wFile:
        wFile.write(json.dumps((ClassweekHttpRequester.getAPICallLogListGivenSessionId( aSessionId, captureDatetime))))