Ejemplo n.º 1
0
 def add_contact(self):
     cname = pb_view.get_data_from_user("add.name?")
     if self.check_contact(cname)[0]:
         pass
         # pb_view.message_to_user("{} already exists".format(cname))
     else:
         ctel = pb_view.get_data_from_user("add.tel?")
Ejemplo n.º 2
0
 def add_contact(self):
     cname = pb_view.get_data_from_user("add.name?")
     if self.check_contact(cname)[0]:
         pb_view.message_to_user("{} already exists".format(cname))
     else:
         ctel = pb_view.get_data_from_user("add.tel?")
         self.phone_book_dict[cname] = pb_contact.PhoneBookContact(cname, ctel)
Ejemplo n.º 3
0
 def update_contact(self):
     cname = pb_view.get_data_from_user("update.name?")
     if self.check_contact(cname)[0]:
         ctel = pb_view.get_data_from_user("update.tel?")
         self.phone_book_dict[cname] = ctel
         pb_view.message_to_user("{} updated".format(cname))
     else:
         pb_view.message_to_user("No such entry in PhoneBook")
Ejemplo n.º 4
0
 def search_contact(self):
     cname = pb_view.get_data_from_user("search.name?")
     if self.check_contact(cname)[0]:
         # pb_view.message_to_user("{}:{}".format(cname, self.phone_book_dict[cname]))
         pass
     else:
         pass
Ejemplo n.º 5
0
 def del_contact(self):
     cname = pb_view.get_data_from_user("delete.name?")
     if self.check_contact(cname)[0]:
         del self.phone_book_dict[cname]
         pb_view.message_to_user("{} deleted".format(cname))
     else:
         pb_view.message_to_user("No such entry in PhoneBook")
Ejemplo n.º 6
0
 def update_contact(self):
     cname = pb_view.get_data_from_user("update.name?")
Ejemplo n.º 7
0
 def del_contact(self):
     cname = pb_view.get_data_from_user("delete.name?")
Ejemplo n.º 8
0
import pb_phone_book_mysql as pb_phone_book
from settings import *


def pb_exit():
    pb_view.message_to_user("Exit.")
    exit()


def pb_help():
    pb_view.message_to_user(HLP_MSG)


pb_view.message_to_user("Welcome to PhoneBook.")
pb_view.message_to_user(HLP_MSG)

new_book = pb_phone_book.PhoneBook()

COMMANDS = {
    'add': new_book.add_contact,
    'del': new_book.del_contact,
    'upd': new_book.update_contact,
    'lst': new_book.list_contacts,
    'exit': pb_exit,
    'srch': new_book.search_contact,
    'help': pb_help
}

while True:
    COMMANDS.get(pb_view.get_data_from_user("?"),
                 pb_phone_book.PhoneBook.default_method)()