def updatePriceRange(username, newPriceRange): users = readUserInfo() lineNum = 0 for i in users: lineNum += 1 if i[0] == username: break if lineNum == 0: return False newPriceRange = utility.listToStringWithComma(newPriceRange) users = open('./Info/userInfo.txt', 'r') data = "" for i in users: lineNum -= 1 if lineNum == 0: start = utility.findSemiColon(i, 7) + 1 end = utility.findSemiColon(i, 8) toWrite = i[0:start] + newPriceRange + i[end:] data += toWrite else: data += i users = open('./Info/userInfo.txt', 'r+') users.write(data) users.close() return True
def updatePassword(username, password_new): file = open('./Info/userInfo.txt', 'r') toWrite = "" for i in file: if i.split(";")[0] == username: start = utility.findSemiColon(i, 1) + 1 end = utility.findSemiColon(i, 2) toWrite += i[:start] + password_new + i[end:] else: toWrite += i file = open('./Info/userInfo.txt', 'r+') file.write(toWrite)
def updateUserName(username_ori, username_new): toWrite = "" file = open('./Info/userInfo.txt', 'r+') for i in file: temp = i.split(";") if temp[0] == username_ori: end = utility.findSemiColon(i,1) toWrite += username_new + i[end:] else: toWrite += i file.close() file = open('./Info/userInfo.txt', 'r+') file.write(toWrite) # change username in timeInfo.txt toWrite = "" file = open('./info/timeInfo.txt', 'r') for i in file: temp = i.split(";") if temp[0] == username_ori: end = utility.findSemiColon(i,1) toWrite += username_new + i[end:] else: toWrite += i file.close() file = open('./Info/timeInfo.txt', 'r+') file.write(toWrite) # change username in profilePhotoInfo.txt toWrite = "" file = open('./Info/profilePhotoInfo.txt', 'r') for i in file: temp = i.split(";") if temp[0] == username_ori: end = utility.findSemiColon(i,1) toWrite += username_new + i[end:] else: toWrite += i file.close() file = open('./Info/profilePhotoInfo.txt', 'r+') file.write(toWrite) # change username in appointmentInfo.txt toWrite = "" file = open('./Info/appointmentInfo.txt', 'r') for i in file: temp = i.split(";") if temp[0] == username_ori: end = utility.findSemiColon(i,1) toWrite += username_new + i[end:] elif temp[1] == username_ori: start = utility.findSemiColon(i,1) + 1 end = utility.findSemiColon(i,2) toWrite += i[:start] + username_new + i[end:] else: toWrite += i file.close() file = open('./Info/appointmentInfo.txt', 'r+') file.write(toWrite)
def updateUserInfo(username, information): users = readUserInfo() user_index = 0 for i in users: if i[0] == username: break user_index += 1 toWrite = "" temp = "" file_write = open('./Info/userInfo.txt', 'r+') for i in file_write: if user_index == 0: # change the part of interested topics start = utility.findSemiColon(i, 4) + 1 end = utility.findSemiColon(i, 5) temp_topics = utility.listToStringWithComma(information[0]) temp = i[0:start] + temp_topics + i[end:] # change the part of job selection start = utility.findSemiColon(temp, 5) + 1 end = utility.findSemiColon(temp, 6) temp = temp[0:start] + information[1] + temp[end:] print(temp) toWrite += temp else: toWrite += i user_index -= 1 file_write = open('./Info/userInfo.txt', 'r+') file_write.write(toWrite) file_write.close()
def changeToFinished(appointment): file = open('./Info/appointmentInfo.txt', 'r') toWrite = "" for i in file: temp = i.split(";") if utility.isSame(appointment, temp): end = utility.findSemiColon(i, 4) + 1 toWrite += i[:end] + "Finished" else: toWrite += i file.close() file = open('./Info/appointmentInfo.txt', 'r+') file.write(toWrite) file.close()
def updatePhotoInfo(username, profilePhoto_new): file = open('./Info/profilePhotoInfo.txt', 'r') toWrite = "" for i in file: if i.split(";")[0] == username: start = utility.findSemiColon(i, 1) + 1 toWrite += i[:start] + profilePhoto_new + "\n" else: toWrite += i file = open('./Info/profilePhotoInfo.txt', 'r+') file.write(toWrite) file.close()