コード例 #1
0
 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
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
 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
コード例 #5
0
 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
コード例 #6
0
 def temporaryTelephoneBook(self,tempList):
     temp=TelephoneBook()
     temp.__setitem__("temp",tempList)
     return temp