Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from LibrarySystem.scr.Book import *
- class BookDB:
- book_list = []
- def readFromBooksTxt(self):
- """
- Function to read from books.txt
- """
- with open("books.txt", "r", encoding="windows-1250") as f:
- for line in f:
- data = line.strip().split(';')
- try:
- book = Book(data[0], data[1], data[2], data[3], data[4])
- self.book_list.append(book)
- except:
- pass
- def writeToBooksTxt(self):
- with open("books.txt", "w", encoding="windows-1250") as f:
- for b in self.book_list:
- f.write("{};{};{};{};{};{}".format(b.id, b.author, b.publication_year, b.title, b.rating, b.is_issued))
- f.write("\n")
- def print_books(self):
- for book in self.book_list:
- print("{} by {}".format(book.title, book.author))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement