fixed problem with empty qso fields, e.g. missing rpt_sent

This commit is contained in:
Michael Clemens 2021-05-22 23:16:32 +02:00
parent f39867b7d7
commit 6444306ecd
1 changed files with 9 additions and 10 deletions

View File

@ -171,16 +171,15 @@ def getQSOsForCallsign(callsign):
# previous QSOs with a specific call sign # previous QSOs with a specific call sign
def getQSOTable(result): def getQSOTable(result):
t = PrettyTable(['Date', 'Time', 'Band', 'Mode', 'RST-S', 'RST-R', 'Comment']) t = PrettyTable(['Date', 'Time', 'Band', 'Mode', 'RST-S', 'RST-R', 'Comment'])
for d in result: for qso in result:
if "qso_date" in d: if "qso_date" in qso:
date = datetime.datetime.strptime(d["qso_date"], '%Y%m%d').strftime('%Y/%m/%d') date = datetime.datetime.strptime(qso["qso_date"], '%Y%m%d').strftime('%Y/%m/%d')
time = datetime.datetime.strptime(d["time_on"], '%H%M').strftime('%H:%M') time = datetime.datetime.strptime(qso["time_on"], '%H%M').strftime('%H:%M')
comment = "" # add missing fields to dict
try: for field in ["band", "mode", "rst_sent", "rst_rcvd", "comment"]:
comment = d["comment"] if field not in qso:
except: qso[field] = ""
comment = "" t.add_row([date, time, qso["band"], qso["mode"], qso["rst_sent"], qso["rst_rcvd"], qso["comment"]])
t.add_row([date, time, d["band"], d["mode"], d["rst_sent"], d["rst_rcvd"], comment])
t.align = "r" t.align = "r"
return t return t