diff options
author | Cody Hiar <cody@hiar.ca> | 2021-02-04 11:26:21 -0700 |
---|---|---|
committer | Cody Hiar <cody@hiar.ca> | 2021-02-04 11:26:21 -0700 |
commit | cd518ff1d07800d46812c016f1b73f9a5f2f4313 (patch) | |
tree | 749b9592f5d000cececed401f8fcc168db0c7fc5 /printer.py | |
parent | 5a15eab4a0f930525cb0f7e97daefdd23113c929 (diff) |
Add printer script for cleaner formatting
Diffstat (limited to 'printer.py')
-rw-r--r-- | printer.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/printer.py b/printer.py new file mode 100644 index 0000000..6e13f2c --- /dev/null +++ b/printer.py @@ -0,0 +1,15 @@ +"""Print the results.""" +from datetime import timedelta + +from mappings import Message, get_session + +session = get_session() +msgs = session.query(Message).order_by(Message.timestamp.desc()).all() + +my_timezone = timedelta(hours=7) + +for msg in msgs: + sent_at = msg.timestamp - my_timezone + sent_at_str = sent_at.strftime("[%m-%d %H:%M]") + text = msg.text[:70].replace("\n", "") + print(f"{sent_at_str} {msg.username:^10} {msg.type:^8} {text}") |