Compare commits

..

No commits in common. "a5ceb76e4356c778d3f05b6130ee1dfaa2f79534" and "007811bde6aa7a1dbc41e331a2f61cc220ecfcd3" have entirely different histories.

2 changed files with 13 additions and 10 deletions

View File

@ -2,7 +2,7 @@
"books": [ "books": [
{ {
"name": "1984", "name": "1984",
"author": "George Orwell", "author": "George Orwell"
"description": "1984 est un roman dystopique de l'écrivain britannique George Orwell. Publié le 8 juin 1949 par Secker & Warburg, il s'agit du neuvième et dernier livre d'Orwell achevé de son vivant", "description": "1984 est un roman dystopique de l'écrivain britannique George Orwell. Publié le 8 juin 1949 par Secker & Warburg, il s'agit du neuvième et dernier livre d'Orwell achevé de son vivant",
"image": "1984.jpg", "image": "1984.jpg",
"review": "ct pas mal", "review": "ct pas mal",

13
main.py
View File

@ -4,11 +4,12 @@ from Book import Book
# Opening JSON file # Opening JSON file
with open('constructor.json', encoding='utf-8') as f: f = open('constructor.json', encoding='utf-8')
data = json.load(f) data = json.load(f)
f.close()
with open('style.css', encoding='utf-8') as f: f = open("style.css")
style = f.read() style = f.read()
f.close()
books = data['books'] books = data['books']
html = "" html = ""
@ -17,11 +18,13 @@ 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"]) 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() html += book.to_html()
with open('cast.html', encoding='utf-8') as f: f = open("cast.html")
text = f.read().replace("{{books}}", html).replace("{{style}}", style) text = f.read().replace("{{books}}", html).replace("{{style}}", style)
f.close()
if len(sys.argv) > 1: if len(sys.argv) > 1:
with open(sys.argv[1], "w", encoding='utf-8') as f: f = open(sys.argv[1], "w", encoding='utf-8')
f.write(text) f.write(text)
f.close()
else: else:
print(text) print(text)