From 6444306ecd81e4fb8a9168716b4d01168cbaf487 Mon Sep 17 00:00:00 2001 From: Michael Clemens Date: Sat, 22 May 2021 23:16:32 +0200 Subject: [PATCH] fixed problem with empty qso fields, e.g. missing rpt_sent --- qrzlogger.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/qrzlogger.py b/qrzlogger.py index e865a81..2361633 100644 --- a/qrzlogger.py +++ b/qrzlogger.py @@ -171,16 +171,15 @@ def getQSOsForCallsign(callsign): # previous QSOs with a specific call sign def getQSOTable(result): t = PrettyTable(['Date', 'Time', 'Band', 'Mode', 'RST-S', 'RST-R', 'Comment']) - for d in result: - if "qso_date" in d: - date = datetime.datetime.strptime(d["qso_date"], '%Y%m%d').strftime('%Y/%m/%d') - time = datetime.datetime.strptime(d["time_on"], '%H%M').strftime('%H:%M') - comment = "" - try: - comment = d["comment"] - except: - comment = "" - t.add_row([date, time, d["band"], d["mode"], d["rst_sent"], d["rst_rcvd"], comment]) + for qso in result: + if "qso_date" in qso: + date = datetime.datetime.strptime(qso["qso_date"], '%Y%m%d').strftime('%Y/%m/%d') + time = datetime.datetime.strptime(qso["time_on"], '%H%M').strftime('%H:%M') + # add missing fields to dict + for field in ["band", "mode", "rst_sent", "rst_rcvd", "comment"]: + if field not in qso: + qso[field] = "" + t.add_row([date, time, qso["band"], qso["mode"], qso["rst_sent"], qso["rst_rcvd"], qso["comment"]]) t.align = "r" return t