def UpdateAddress(self, key, data): if key == None: return key = key.replace(" ", "_") if key == "New Address": self.Address = data writeout(f"UPDATED ADDRESS OF '{self.Reg}' to '{data}'", color='green')
def UpdateOwner(self, key, data): if key == None: return key = key.replace(" ", "_") if key == "New Owner": self.Owner = data writeout(f"UPDATED OWNER OF '{self.Reg}' to '{data}'", color='green')
def UpdateStatus(self, key, data): if key == None: return key = key.replace(" ", "_") if key == "New Status": self.Status = data writeout(f"UPDATED STATUS OF '{self.Reg}' to '{data}'", color='green')
def send(self): del self.Updates exists = self.exists delete = self.delete del self.exists del self.delete columns = str(self.__dict__.keys())[11:-2] data = str(self.__dict__.values())[13:-2] columns = columns.replace("'", "") #DELETE FROM planes WHERE Reg = '23456' if exists and delete: mycursor.execute(f"DELETE FROM planes WHERE Reg = '23456'") db.commit() writeout(f"**********{self.Reg} DELETED SUCCESSFULLY**********", color='green') return elif (delete): writeout( f"WARNING: {self.Reg} DIDNT EXIST. DELETION CONSIDERED SUCCESSFULL", color='yellow') return if exists: Reg = self.Reg del self.Reg for key in self.__dict__: mycursor.execute( f"UPDATE planes SET {key} = '{self.__dict__[key]}' WHERE Reg = {Reg}" ) db.commit() writeout("**********UPDATE SENT SUCCESSFULLY**********", color='green') else: try: request = f"INSERT INTO planes ({columns}) VALUES ({data})" mycursor.execute(request) db.commit() writeout("**********INSERTION SENT SUCCESSFULLY**********", color='green') except: writeout("ERROR: FAILED TO UPLOAD REQUEST:\n" + request, color='red')
def Register(self, key, data): if key == None: return key = key.replace(" ", "_") self.__dict__[key] = data writeout(f"REGISTER '{self.Reg}' IS STORING: {key}, {data}", sep='')
for line in email: if not line: if DATAq != None: DATAq.send() DATAq = None continue if not ignore and (line != 'None'): #Line is relevant and not empty if "====" in line: Get_New_Section = True continue if Get_New_Section: try: Current_Section = a.match(line)[0][1:-1] Current_Section = Current_Section.strip() writeout("SECTION CHANGED TO: " + Current_Section, color="blue") except TypeError: writeout("WARNING: NO HEADER DEFINED WHEN READING: \n" + line, color='yellow') continue Get_New_Section = False ignore = True continue try: Current_Header, Data_Read = line.split(':', 1) Current_Header = Current_Header.strip() Data_Read = Data_Read.strip() except ValueError: writeout("ERROR: FAILED TO EXTRACT HEADER/DATA FROM:\n" + line, color='red') DATAque[0][1] += " " + line