예제 #1
0
def main():

    _phone_book = PhoneBook()
    print("Phone Book is Open")

    phone_book_help()
    for line in sys.stdin:
        if (line.rstrip() == '1'):
            input_handler['1'](_phone_book)
        elif (line.rstrip() == '2'):
            input_handler['2'](_phone_book)
        elif (line.rstrip() == '3'):
            input_handler['3'](_phone_book)
        elif (line.rstrip() == '4'):
            input_handler['4'](_phone_book)
        elif (line.rstrip() == '5'):
            input_handler['5'](_phone_book)
        elif (line.rstrip() == '6'):
            input_handler['6'](_phone_book)
        elif (line.rstrip() == '7'):
            input_handler['7'](_phone_book)
        elif (line.rstrip() == '8'):
            input_handler['8'](_phone_book)
        elif (line.rstrip() == 'q'):
            break
        else:
            print("Unknown input")
        phone_book_help()
예제 #2
0
def before_feature(context, feature):
    if feature.name == 'New numbers':
        phone_book = PhoneBook(phone_numbers=[333],
                               address_book={
                                   'name': 'mahshad',
                                   'last_name': 'esl'
                               })
        context.phone_book = phone_book
        logging.info(context.phone_book.phone_numbers)
    def __init__(self):

        config = ConfigParameters()
        self.phone_book_file_db = config.get_phone_book_file_db()
        dict = self.phone_book_file_db.load_phone_book_from_file()
        self.book = PhoneBook()
        self.book.load_phone_book_from_dict(dict)

        self.controller = {
            1: self._create_phone_number,
            2: self._get_phone_by_name,
            3: self._get_customer_by_phone,
            4: self._delete_by_name,
            5: self._show_all
        }
예제 #4
0
def main() -> bool:    
    """
    Docstring
    """
    print("Hello, dear User! I'm your pleasant programm to work with phone books.")

    global phone_book
    phone_book = PhoneBook()

    while True:
        user_input = get_user_input()

        if handle_user_input(user_input):
            continue
        else:
            break

    return phone_book.save_phone_book()
예제 #5
0
def processInput():
    phoneBook = PhoneBook()
    input = sys.stdin.readlines()
    n = int(input.pop(0))
    
    #process phone book entries
    for idx in range(n):
        entry = input[idx].rstrip()
        isEntryValid = PhoneBook.validateEntry(entry)
        if(isEntryValid):
            phoneBook.addEntry(entry)
        else:
            errorMsg = "Invalid entry: " + entry
            logging.error(errorMsg)
            
    del input[:n] #delete phone book entries and remain with queries only
        
    #process queries
    for idx in range(n):
        name = input[idx].rstrip()
        phoneBook.displayEntry(name)
예제 #6
0
from phone_book import PhoneBook
from file_handler import FileHandler
import os
from constants import literatls, data_filename, query_filename, output_filename

if __name__ == '__main__':
    path = os.getcwd()

    phone_book = PhoneBook(path + data_filename)
    queries = FileHandler.read_file(path + query_filename, literatls["TXT"],
                                    "r")
    for lastname in queries.readlines():
        FileHandler.write_file(
            path + output_filename,
            lastname.rsplit()[0],
            phone_book.search_on_last_name(lastname.rstrip()))
예제 #7
0
from contact import Contact
from phone_book import PhoneBook

print("Phone book")

phoneBook = PhoneBook()


def write_contacts(phone_book: PhoneBook):
    if phone_book.get_count() == 0:
        print("List is empty")
        return

    for contact in phone_book.get_contacts():
        print(
            f'Name: {contact.get_name()} PersonalPhone: {contact.get_personal_phone()} Phone {contact.get_phone()}'
            f' Description {contact.get_description()}')


def add_contact(phone_book: PhoneBook):
    name = input("Enter name")
    contact = Contact(name)

    contact.personal_phone = input("Enter PersonalPhone")
    contact.phone = input("Enter Phone")
    contact.description = input("Enter Description")

    phone_book.add_contact(contact)

    print("Contact successfully added")
예제 #8
0
 def setUp(self):
     '''initialization'''
     self.initPhoneBook = PhoneBook()
예제 #9
0
 def setUp(self):
     self.pb = PhoneBook(FILENAME)
 def setUp(self) -> None:
     self.phone_book = PhoneBook()