def delete_ab_record(id): if not id: return (f'Soryy, for deleting type id record after command') else: ab = loadAB() ab.delete_record(int(id)) pb.save_addressBook(ab)
def update_ab(record): global CURRENT_RECORD, CURRENT_ID delete_ab_record(CURRENT_ID) ab = loadAB() ab.add_record(record) pb.save_addressBook(ab) CURRENT_ID = None CURRENT_RECORD = None
def add_contact(*args): ab = loadAB() name = input_name() address = pb.Address(input('Contact address (optional): ')) phone = input_phone() birthday = input_birthday() email = input_email() record = pb.Record(name, address, phone, birthday, email) confirm = input(f'Add record {record} to address book (y/n)?: ') if confirm.lower() == 'y': ab.add_record(record) pb.save_addressBook(ab)