Exemplo n.º 1
0
 def __init__(self):
     self.phone_book_ser = pb_db.PhoneBookDB(FILE_FORMAT)
     try:
         self.phone_book_dict = self.phone_book_ser.get_data_from_file()
     except (EOFError, IOError):
         pb_view.message_to_user("Error loading data from file. Starting new phone_book.")
         self.phone_book_dict = {}
Exemplo n.º 2
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")
Exemplo n.º 3
0
 def default_method():
     pb_view.message_to_user("Bad command. Please input correct one!")
Exemplo 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]))
     else:
         pb_view.message_to_user(self.check_contact(cname)[1])
Exemplo n.º 5
0
def pb_exit():
    pb_view.message_to_user("Exit.")
    exit()
Exemplo n.º 6
0
def pb_help():
    pb_view.message_to_user(HLP_MSG)
Exemplo n.º 7
0
import pb_view_telnet as pb_view
# import pb_phone_book
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: