Refactor a bit

This commit is contained in:
KnugiHK
2023-06-20 14:50:57 +08:00
parent 4fa360a389
commit cc0105647a
3 changed files with 14 additions and 33 deletions

View File

@@ -702,10 +702,7 @@ def create_html(
contact, contact,
w3css, w3css,
f"{safe_file_name}-{current_page + 1}.html", f"{safe_file_name}-{current_page + 1}.html",
chat.my_avatar, chat
chat.their_avatar,
chat.their_avatar_thumb,
chat.status
) )
render_box = [message] render_box = [message]
current_size = 0 current_size = 0
@@ -724,10 +721,7 @@ def create_html(
contact, contact,
w3css, w3css,
False, False,
chat.my_avatar, chat
chat.their_avatar,
chat.their_avatar_thumb,
chat.status
) )
else: else:
render_box.append(message) render_box.append(message)
@@ -741,10 +735,7 @@ def create_html(
contact, contact,
w3css, w3css,
False, False,
chat.my_avatar, chat
chat.their_avatar,
chat.their_avatar_thumb,
chat.status
) )
if current % 10 == 0: if current % 10 == 0:
print(f"Generating chats...({current}/{total_row_number})", end="\r") print(f"Generating chats...({current}/{total_row_number})", end="\r")

View File

@@ -368,10 +368,7 @@ def create_html(
contact, contact,
w3css, w3css,
f"{safe_file_name}-{current_page + 1}.html", f"{safe_file_name}-{current_page + 1}.html",
chat.my_avatar, chat
chat.their_avatar,
chat.their_avatar_thumb,
chat.status
) )
render_box = [message] render_box = [message]
current_size = 0 current_size = 0
@@ -390,10 +387,7 @@ def create_html(
contact, contact,
w3css, w3css,
False, False,
chat.my_avatar, chat
chat.their_avatar,
chat.their_avatar_thumb,
chat.status
) )
else: else:
render_box.append(message) render_box.append(message)
@@ -407,10 +401,7 @@ def create_html(
contact, contact,
w3css, w3css,
False, False,
chat.my_avatar, chat
chat.their_avatar,
chat.their_avatar_thumb,
chat.status
) )
if current % 10 == 0: if current % 10 == 0:
print(f"Generating chats...({current}/{total_row_number})", end="\r") print(f"Generating chats...({current}/{total_row_number})", end="\r")

View File

@@ -69,24 +69,23 @@ def rendering(
contact, contact,
w3css, w3css,
next, next,
my_avatar, chat,
their_avatar,
their_avatar_thumb,
status
): ):
if their_avatar_thumb is None and their_avatar is not None: if chat.their_avatar_thumb is None and chat.their_avatar is not None:
their_avatar_thumb = their_avatar their_avatar_thumb = chat.their_avatar
else:
their_avatar_thumb = chat.their_avatar_thumb
with open(output_file_name, "w", encoding="utf-8") as f: with open(output_file_name, "w", encoding="utf-8") as f:
f.write( f.write(
template.render( template.render(
name=name, name=name,
msgs=msgs, msgs=msgs,
my_avatar=my_avatar, my_avatar=chat.my_avatar,
their_avatar=their_avatar, their_avatar=chat.their_avatar,
their_avatar_thumb=their_avatar_thumb, their_avatar_thumb=their_avatar_thumb,
w3css=w3css, w3css=w3css,
next=next, next=next,
status=status, status=chat.status,
) )
) )