Beispiel #1
0
def gen_books():
    books_list = []
    data = pd.read_csv('catalogue.csv')
    data = data[(data.resource_type == 'Book')]
    data = data.loc['title', 'author', 'code', 'year', 'total_copies',
                    'available_copies'].values
    for i in range(len(data)):
        obj_book = Book()
        obj_book.title = data[i, 0]
        obj_book.author = data[i, 1]
        obj_book.code = data[i, 2]
        obj_book.year = data[i, 3]
        obj_book.total_copies = data[i, 4]
        obj_book.available_copies = data[i, 5]
    return books_list
Beispiel #2
0
    def add_books(self):
        if not self.info_confirm('1'):
            return

        while True:
            book = Book()
            book_id = str(random.randint(100000, 999999))
            while book_id in self.df_books.book_id.values:
                book_id = random.randint(100000, 999999)
            book.book_id = book_id
            ISBN = input("Please enter ISBN of the book: ")
            book.ISBN = ISBN
            title = input("Please enter title of the book: ")
            book.title = title.capitalize()
            author = input("Please enter author of the book: ")
            book.author = author.capitalize()
            publisher = input("Please enter publisher of the book: ")
            book.publisher = publisher.capitalize()
            language = input("Please enter language of the book: ")
            book.language = language
            while True:
                date = input("Please enter publication_date of the book(Mon/Day/Year): ")
                try:
                    datetime.strptime(date, "%m/%d/%Y")
                    book.publication_date = date
                    break
                except ValueError:
                    print("Oops!  That was no valid date.  Try again...")
            row = len(self.df_books)
            for a in [attr for attr in dir(book) if not attr.startswith('__')]:
                self.df_books.loc[row, [a]] = getattr(book, a)
            print("The following book has been added to the library:")
            print(self.df_books[-1:].to_string(index=False))
            print("""           ===========Please Select===========
                    1. Keep adding books
                    Any. Exit
                                          """)
            choice = input("Please enter your choice: ")
            if choice == '1':
                continue
            else:
                break
Beispiel #3
0
from Book import Book
import pickle
import time
"""
This file just for create some sample book object to database
"""

if __name__ == '__main__':
    book_list = []

    my_book = Book("Four in Camp", "QUINNEYS.jpg", 20)
    my_book.author = "Ralph Henry Barbour"
    my_book.summary = "A STORY OF SUMMER ADVENTURES IN THE NEW HAMPSHIRE WOODS"
    my_book.type = "Adventures"
    my_book.NumOfRead = 18
    my_book.cover_page = "QUINNEYS.jpg"
    my_book.book_file = "Four in Camp.txt"
    my_book.contribute_by = "kaiying"
    my_book.last_time_read = time.time()
    my_book.superuser_set_point = 0
    my_book.complain = []
    my_book.last_time_read = time.time()
    book_list.append(my_book)

    my_book = Book("La chair et le sang", "QUINNEYS.jpg", 5)
    my_book.author = "Franois Mauriac"
    my_book.summary = "Since the introduction of the tungsten lamp some five years ago," \
                      " the manufacturers have attempted continually to produce smaller " \
                      "and smaller units in the standard voltages."
    my_book.type = "Education"
    my_book.book_file = "La chair et le sang.txt"
Beispiel #4
0
from Book import Book
import pickle
import time

"""
This file just for create some sample book object to database
"""

if __name__ == '__main__':
    book_list = []

    my_book = Book("Four in Camp","QUINNEYS.jpg", 20)
    my_book.author = "Ralph Henry Barbour"
    my_book.summary = "A STORY OF SUMMER ADVENTURES IN THE NEW HAMPSHIRE WOODS"
    my_book.type = "Adventures"
    my_book.NumOfRead = 18
    my_book.cover_page = "QUINNEYS.jpg"
    my_book.book_file = "Four in Camp.txt"
    my_book.contribute_by = "kaiying"
    my_book.last_time_read = time.time()
    my_book.superuser_set_point = 0
    my_book.complain = []
    my_book.last_time_read = time.time()
    book_list.append(my_book)

    my_book = Book("La chair et le sang","QUINNEYS.jpg", 5)
    my_book.author = "Franois Mauriac"
    my_book.summary = "Since the introduction of the tungsten lamp some five years ago," \
                      " the manufacturers have attempted continually to produce smaller " \
                      "and smaller units in the standard voltages."
    my_book.type = "Education"