Ejemplo n.º 1
0
def list_books():
    try:
        books = database.get_all_books()
    except FileNotFoundError:
        database.create_book_table()
        books = database.get_all_books()
    for book in books:
        read = "YES" if book['read'] else "NO"
        print(f"{book['name']} by {book['author']}, read: {read}")
Ejemplo n.º 2
0
def list_books():
    books = database.get_all_books()
    for book in books:
        read = 'YES' if book['read'] else 'NO'
        print(
            f"{book['name'].capitalize()} by {book['author'].capitalize()}, read {read}"
        )
Ejemplo n.º 3
0
def list_books():
    """[list all the books available in the database]
    """
    books = database.get_all_books()
    for book in books:
        read = 'YES' if book['read'] else 'NO'
        print(f"{book['name']} by {book['author']},read:{read}")
Ejemplo n.º 4
0
def list_books():  # ALl books are shown here
    books = database.get_all_books()  # This get all the books from DB
    for book in books:
        # yes will come if book == true else no
        read = "Yes" if book["read"] else "No"
        # printing books list by fstring
        print(f"Book {book['name']} By Author {book['author']} is read {read}")
Ejemplo n.º 5
0
def list_books():
    books = database.get_all_books()
    for book in books:
        name = book['name']
        author = book['author']
        read = 1 if book['read'] else 0
        print(f"- {name} by {author}. read: {read}.")
Ejemplo n.º 6
0
def list_books():
    # for book in db.books:
    #     print(f"Title : {book['name']}\nAuthor: {book['author']}")
    books = db.get_all_books()
    for book in books:
        read = 'Yes' if book['read'] else 'No'
        print(f"{book['name']} by {book['author']}, read : {read}")
Ejemplo n.º 7
0
def list_books():
    books = database.get_all_books()
    print('\n====== All Books =====')
    for book in books:
        read = green('YES') if book['read'] else red('NO')
        print(
            f"{magenta(book['name'])} by {blue(book['author'])}, read: {read}")
    print('======================\n')
Ejemplo n.º 8
0
def list_book():
    books = database.get_all_books()
    if not books:  # if the file is empty
        print(f'No books stored')
    else:
        for book in books:
            read = 'YES' if book['read'] else 'NO'
            print(f"{book['name']} by {book['author']}, read: {read}")
Ejemplo n.º 9
0
def list_books():
    """
        List the books from the database using the print_book_list function.
    """
    books = database.get_all_books()

    
    print_book_list(books)
Ejemplo n.º 10
0
def list_books():
    """List all books in the database."""
    books = database.get_all_books()

    for number, book in enumerate(books, 1):
        read = 'yes' if book['read'] else 'no'
        print(
            f"{[number]} - {book['name']} by {book['author']} — Read: {read}")
Ejemplo n.º 11
0
def prompt_get_all_books():
    books = database.get_all_books()

    if books == []:
        print("\nYour list is empty!")

    for book in books:
        read = 'YES' if book['read'] else 'NO'
        print(f"{book['name']} by {book['author']}, read: {read}")
Ejemplo n.º 12
0
def list_books():
    books = database.get_all_books()

    if len(books) == 0:
        print("No books, feel free to add some :-)")
        return

    for book_id, book in enumerate(books):
        print_book(book_id, book)
Ejemplo n.º 13
0
    def look_after_name_or_author(expected, finder):
        found = []
        books = database.get_all_books()
        
        for book in books:
            if finder(book) == expected:
                found.append(book)

        return found
Ejemplo n.º 14
0
def list_books():  # Print out all books in a nice format
    library = database.get_all_books()

    print(f'You have {len(library)} book(s) in your library.')
    for book in library:
        book_title = book['title']
        book_author = book['author']
        book_read = "Yes" if book['read'] == "1" else "No"

        print(f'{book_title}, by {book_author}, read: {book_read}')
Ejemplo n.º 15
0
def list_books():
    """
    Show all the book in our list
    :return:
    """
    books = database.get_all_books()
    print('List of books:')
    for book in books:
        read = 'YES' if book['read'] == 1 else 'NO'
        print(f"{ book['name'] } by { book['author'] }, read: { read }")
Ejemplo n.º 16
0
def menu():
    database.create_book_table()
    user_input = input(USER_CHOICE)
    while user_input != "q":
        if user_input == "a":
            name = input("Enter book name:")
            author = input("Enter book author:")
            database.a(name, author)
        elif user_input == "r":
            user_input = input("What title are you reading?: ")
            database.r(user_input)
        elif user_input == "l":
            books = database.get_all_books()
            for book in books:
                database.l(book)

        elif user_input == "d":
            user_input = input("What title would like to delete: ")
            database.d(user_input)
        elif user_input == "q":
            break
        else:
            print("Unknown command. Please try again!")
        user_input = input(USER_CHOICE)
Ejemplo n.º 17
0
def list_books():
    books = database.get_all_books()
    for i, book in enumerate(books):
        print(f'B{i + 1}\n Namn: {book["name"]}\n Author: {book["author"]}\n Read: {"Yes" if book["read"] else "Nope"}\n')
Ejemplo n.º 18
0
def list_books():
    books = database.get_all_books()
    for book in books:
        read = 'YES YOU READ THIS BOOK' if book[
            'read'] == 'True' else "YOU HAVEN'T READ THE BOOK YET"
        print(f"{book['name']} by author {book['author']},read:{read}")
Ejemplo n.º 19
0
def list_books():
    for book in database.get_all_books():
        read = 'YES' if book[
            'read'] else 'NO'  # book[3] will be a falsy value (0) if not read
        print(f"{book['name']} by {book['author']} — Read: {read}")
Ejemplo n.º 20
0
def list_books():
    books = database.get_all_books()
    for book in books:
        read = 'Yes' if book['read'] == '1' else 'No'
        print(f"{book['name']} by {book['author']} - Read: {read}")
Ejemplo n.º 21
0
def list_books():
    books = database.get_all_books()
    for book in books:
        read = 'YES' if book['read'] == 1 else 'NO'
        print(f"{book['name']} escrito por {book['name']} leido: {read}")
Ejemplo n.º 22
0
def list_books():
    books = database.get_all_books()
    for n in books:
        Read = 'YES' if n['read'] else 'NO'
        print(f'Name: {n["name"]}, Author: {n["author"]}, Read: {Read}')
Ejemplo n.º 23
0
def list_books():
        books = database.get_all_books()
        for book in books:
                read = 'YES' if book['read'] else 'NO' #python reads a 1 integer as True, a 0 integer as False
                print(f"{book['name']} by {book['author']}, read: {read}")
Ejemplo n.º 24
0
def list_books():
    for book in database.get_all_books():
        read = 'YES' if book[
            3] else 'NO'  # book[3] will be a falsy value (0) if not read
        print(f'{book[1]} by {book[2]} — Read: {read}')
Ejemplo n.º 25
0
def list_books():
    books = database.get_all_books()
    for i, book in enumerate(books):
        read = 'YES' if book['read'] else 'NO'
        print(f"{str(i + 1).zfill(2)} - {book['name']} by {book['author']}, read: {read}")
Ejemplo n.º 26
0
def list_book():
    books = database.get_all_books()
    for book in books:
        read = 'YES' if book['read'] == "1" else "NO"
        print(f"{book['name']} by {book['author']}, read: {read}")
Ejemplo n.º 27
0
def list_books():
    books = database.get_all_books()
    for book in books:
        read = 'YES' if book['read'] == 1 else 'NO'
        print(f"{book['name']} by {book['author']} is read : {read}")
Ejemplo n.º 28
0
def list_books():
    books = database.get_all_books()
    for book in books:
        read = 'YES' if book['read'] else 'NO'
        print('{} by {} , read: {}'.format(book['name'],book['author'],book['read']))
Ejemplo n.º 29
0
def list_books():
    for book in database.get_all_books():
        read = 'YES' if book['read'] else 'NO'
        print(f"{book['name']} by {book['author']} — Read: {read}")
Ejemplo n.º 30
0
def list_books():
    books = db.get_all_books()
    for book in books:
        read = 'YES' if book['read'] else 'NO'
        print(f"{book['name']} by {book['author']}, read: {read}")