def edit(edit_book): print('''I'm going to show you each element of the book. If you don't want to change it, just press enter. Otherwise, enter a new value. For multiple authors and tags, separate them by a comma. e.g. author1,author2,author3''') new_book = {} new_book['barcode'] = input("Barcode: " + str(edit_book.bc)) new_book['isbn'] = input("ISBN: " + str(edit_book.isbn)) new_book['title'] = input("Title: " + str(edit_book.title)) # doesn't pull info for anything below. new_book['authors'] = input("Authors: " + str(edit_book.authors)) new_book['pages'] = input("Number of Pages: " + str(edit_book.pages)) new_book['publ_year'] = input("Publication Year: " + str(edit_book.publ_year)) new_book['publisher'] = input("Publisher: " + str(edit_book.publisher)) new_book['location'] = input("Location: " + str(edit_book.location)) new_book['description'] = input("Description: " + str(edit_book.description)) new_book['call_num'] = input("Call number: " + str(edit_book.call_num)) new_book['tags'] = input("Tags: " + str(edit_book.tags)) for key, value in new_book.items(): if value == '': new_book[key] = None old_bc = edit_book.bc # we need this to ensure we don't create a duplicate db entry edit_book.edit(new_book['barcode'], new_book['isbn'], new_book['title'], new_book['authors'], new_book['pages'], new_book['publ_year'], new_book['publisher'], new_book['location'], new_book['description'], new_book['call_num'], new_book['tags']) the_db = Bdb(dbLocation) if edit_book.bc is None: the_db.store(edit_book) else: the_db.delete(Book(old_bc)) the_db.store(edit_book) print("Success!")
def delete_book(): to_do = input('''We're going to delete a book. Do you have the barcode? [y/N]: ''') if to_do.strip() == "" or to_do.strip().lower() == "n": results = search() i = 1 for item in results: print((i + ") " + item)) # not sure how this will come out. del_me = input("Which one is it? ") del_me = int(del_me) del_me = results[del_me - 1] del_me = del_me.split(",") del_me = Book(del_me[0]) # this is really fudged atm. serious testing needed the_db = Bdb(dbLocation) the_db.delete(del_me) print("Deleted.") elif to_do.strip().lower() == "y": del_me = input("Ok, enter it now: ") if del_me.strip() == "": print("Invalid input.") else: del_me = int(del_me) del_me = Book(del_me) the_db = Bdb(dbLocation) the_db.delete(del_me) print("Deleted.")
def delete_book(): to_do = input( '''We're going to delete a book. Do you have the barcode? [y/N]: ''') if to_do.strip() == "" or to_do.strip().lower() == "n": results = search() i = 1 for item in results: print((i + ") " + item)) # not sure how this will come out. del_me = input("Which one is it? ") del_me = int(del_me) del_me = results[del_me - 1] del_me = del_me.split(",") del_me = Book( del_me[0]) # this is really fudged atm. serious testing needed the_db = Bdb(dbLocation) the_db.delete(del_me) print("Deleted.") elif to_do.strip().lower() == "y": del_me = input("Ok, enter it now: ") if del_me.strip() == "": print("Invalid input.") else: del_me = int(del_me) del_me = Book(del_me) the_db = Bdb(dbLocation) the_db.delete(del_me) print("Deleted.")
def edit(edit_book): print('''I'm going to show you each element of the book. If you don't want to change it, just press enter. Otherwise, enter a new value. For multiple authors and tags, separate them by a comma. e.g. author1,author2,author3''') new_book = {} new_book['barcode'] = input("Barcode: " + str(edit_book.bc)) new_book['isbn'] = input("ISBN: " + str(edit_book.isbn)) new_book['title'] = input( "Title: " + str(edit_book.title)) # doesn't pull info for anything below. new_book['authors'] = input("Authors: " + str(edit_book.authors)) new_book['pages'] = input("Number of Pages: " + str(edit_book.pages)) new_book['publ_year'] = input("Publication Year: " + str(edit_book.publ_year)) new_book['publisher'] = input("Publisher: " + str(edit_book.publisher)) new_book['location'] = input("Location: " + str(edit_book.location)) new_book['description'] = input("Description: " + str(edit_book.description)) new_book['call_num'] = input("Call number: " + str(edit_book.call_num)) new_book['tags'] = input("Tags: " + str(edit_book.tags)) for key, value in new_book.items(): if value == '': new_book[key] = None old_bc = edit_book.bc # we need this to ensure we don't create a duplicate db entry edit_book.edit(new_book['barcode'], new_book['isbn'], new_book['title'], new_book['authors'], new_book['pages'], new_book['publ_year'], new_book['publisher'], new_book['location'], new_book['description'], new_book['call_num'], new_book['tags']) the_db = Bdb(dbLocation) if edit_book.bc is None: the_db.store(edit_book) else: the_db.delete(Book(old_bc)) the_db.store(edit_book) print("Success!")