Example #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
Example #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
Example #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 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()