2024-08-05 15:14:49 -04:00
|
|
|
import json
|
2024-08-06 06:56:44 -04:00
|
|
|
import sys
|
2024-08-05 15:14:49 -04:00
|
|
|
from Book import Book
|
|
|
|
|
2024-08-06 06:56:44 -04:00
|
|
|
|
2024-08-05 15:14:49 -04:00
|
|
|
# Opening JSON file
|
2024-08-05 15:28:24 -04:00
|
|
|
f = open('constructor.json', encoding='utf-8')
|
2024-08-05 15:14:49 -04:00
|
|
|
data = json.load(f)
|
2024-08-05 15:37:29 -04:00
|
|
|
f.close()
|
|
|
|
f = open("style.css")
|
|
|
|
style = f.read()
|
2024-08-05 15:14:49 -04:00
|
|
|
f.close()
|
|
|
|
|
|
|
|
books = data['books']
|
|
|
|
html = ""
|
|
|
|
|
|
|
|
for book_data in books:
|
2024-08-06 08:45:37 -04:00
|
|
|
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"])
|
2024-08-05 15:14:49 -04:00
|
|
|
html += book.to_html()
|
|
|
|
|
|
|
|
f = open("cast.html")
|
2024-08-06 06:56:44 -04:00
|
|
|
text = f.read().replace("{{books}}", html).replace("{{style}}", style)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
f = open(sys.argv[1], "w", encoding='utf-8')
|
|
|
|
f.write(text)
|
|
|
|
f.close()
|
|
|
|
else:
|
|
|
|
print(text)
|