def sortTelephoneBook(self): newTelephoneBook=TelephoneBook() #Makes a new _telephone_book sorted_list_of_contacts = sorted(self._telphone_book.items(), key=lambda t: t[1].__getitem__(0)) #sorts a items in the book and returns a list iterattion=1 for key in sorted_list_of_contacts: newTelephoneBook.__setitem__(iterattion,key[1])#writes to the new book items from the sorted list iterattion+=1 self.set_telephone_book(newTelephoneBook)#sets new book as a telephone book return newTelephoneBook
def temporary_telephone_book(self, temp_list): ''' :param temp_list: List of parameters for a new contact. :type list :return: TelephoneBook Function temporary_telephone_book makes a temporary object of class TelephoneBook. ''' temp=TelephoneBook() temp.__setitem__("temp", temp_list) return temp
def findContactSting(self,mySring): #dodac zmiane wielkosci liter na lower zeby poprawnie wyszukac znak i pozniej wrocic myList=mySring.split() newDictionary=TelephoneBook() keyList=[] for m in myList: for t in self._telphone_book.items(): for p in t[1]: if p.lower().__contains__(m.lower()): keyList.append(t[0]) break for k in keyList: newDictionary.__setitem__(k, self._telphone_book[k]) return newDictionary
def sort_telephone_book(self): ''' :returns: TelephoneBook Function sorts the object's Procosseng class attribute: telephone_book. ''' new_telephone_book=TelephoneBook() #Makes a new _telephone_book sorted_list_of_contacts = sorted(self._telephone_book.items(), key = lambda t: t[1].__getitem__(0)) #sorts a items in the book and returns a list iterattion = 1 for key in sorted_list_of_contacts: new_telephone_book.__setitem__(iterattion,key[1])#writes to the new book items from the sorted list iterattion+=1 self.set_telephone_book(new_telephone_book)#sets new book as a telephone book return new_telephone_book
def find_contact_sting(self, my_sring): ''' :param my_sring: String to be found :type my_sring: str :returns: TelephoneBook Returns a TelephoneBook object with all the data that contains desired string. ''' my_list=my_sring.split() new_dictionary=TelephoneBook() key_list=[] for m in my_list: for t in self._telephone_book.items(): for p in t[1]: if p.lower().__contains__(m.lower()): key_list.append(t[0]) break for k in key_list: new_dictionary.__setitem__(k, self._telephone_book[k]) return new_dictionary
def temporaryTelephoneBook(self,tempList): temp=TelephoneBook() temp.__setitem__("temp",tempList) return temp