def load_obj_record(rec): if CURRENT_MODE == '1': return pb.Record(pb.Name(rec['name']), pb.Email(rec['email']), pb.Address(rec['address']), pb.Birthday(rec['birthday']), *(pb.Phone(i) for i in rec['phones'])) elif CURRENT_MODE == '2': return nb.NoteRecord(nb.Note(rec['Note']), nb.Teg(rec['Teg']))
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)
def add_contact(*args): nam = input_name() #address = pb.Address(input('Contact address (optional): ')) phone = input_phone() birthd = input_birthday() emal = input_email() print(nam.value) record = pb.Record(nam, phone, birthd, emal) new_user = md.User(name=nam.value, email=emal.value, birthday=birthd.value) new_phon = md.Phone(phone=phone.value, user=new_user) confirm = input(f'Add record {record} to address book (y/n)?: ') if confirm.lower() == 'y': session.add(new_user) session.add(new_phon) session.commit()