From 5dd8c3bc11bf640f61bcbe2b69869ffbcc09118a Mon Sep 17 00:00:00 2001 From: Chris Arderne Date: Mon, 25 Mar 2024 09:37:46 +0000 Subject: [PATCH] fix html output --- sigexport/main.py | 8 +++++--- sigexport/utils.py | 12 +++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sigexport/main.py b/sigexport/main.py index c94969f..a793e12 100755 --- a/sigexport/main.py +++ b/sigexport/main.py @@ -212,7 +212,7 @@ def main( paginate = int(1e20) if html_output: - html_.prep_html(dest) + html.prep_html(dest) for key, messages in chat_dict.items(): name = contacts[key].name # some contact names are None @@ -233,12 +233,14 @@ def main( print(msg.to_md(), file=md_f) print(msg.dict_str(), file=js_f) if html_output: - ht = html_.create_html(name=name, messages=messages, msgs_per_page=paginate) + ht = html.create_html( + name=name, messages=messages, msgs_per_page=paginate + ) print(ht, file=ht_f) finally: md_f.close() js_f.close() - if html_output: + if ht_f: ht_f.close() secho("Done!", fg=colors.GREEN) diff --git a/sigexport/utils.py b/sigexport/utils.py index 9343ecf..1497335 100644 --- a/sigexport/utils.py +++ b/sigexport/utils.py @@ -14,12 +14,18 @@ def dt_from_ts(ts: float) -> datetime: def parse_datetime(input_str: str) -> datetime: last_exception = None - for format in ["%Y-%m-%d %H:%M", "%Y-%m-%d, %H:%M", "%Y-%m-%d %H:%M:%S", "%Y-%m-%d, %H:%M:%S"]: + for fmt in [ + "%Y-%m-%d %H:%M", + "%Y-%m-%d, %H:%M", + "%Y-%m-%d %H:%M:%S", + "%Y-%m-%d, %H:%M:%S", + ]: try: - return datetime.strptime(input_str, format) + return datetime.strptime(input_str, fmt) except ValueError as e: last_exception = e - raise(last_exception) + raise (last_exception) + def version_callback(value: bool) -> None: """Get sigexport version."""