import json import sys from Book import Book # Opening JSON file with open('constructor.json', encoding='utf-8') as f: data = json.load(f) with open('style.css', encoding='utf-8') as f: style = f.read() books = data['books'] html = "" for book_data in books: book = Book(book_data["name"], book_data["author"], book_data["description"], book_data["image"], book_data["review"], book_data["release_date"], book_data["reading_date"]) html += book.to_html() with open('cast.html', encoding='utf-8') as f: text = f.read().replace("{{books}}", html).replace("{{style}}", style) if len(sys.argv) > 1: with open(sys.argv[1], "w", encoding='utf-8') as f: f.write(text) else: print(text)