not1mm 25.5.26.1__py3-none-any.whl → 25.6.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. not1mm/__main__.py +66 -43
  2. not1mm/data/MASTER.SCP +2636 -2654
  3. not1mm/data/cty.json +1 -1
  4. not1mm/data/new_contest.ui +5 -0
  5. not1mm/lib/database.py +14 -45
  6. not1mm/lib/edit_station.py +5 -5
  7. not1mm/lib/plugin_common.py +21 -0
  8. not1mm/lib/super_check_partial.py +28 -12
  9. not1mm/lib/version.py +1 -1
  10. not1mm/logwindow.py +4 -0
  11. not1mm/plugins/ari_dx.py +11 -11
  12. not1mm/plugins/arrl_160m.py +13 -13
  13. not1mm/plugins/arrl_dx_cw.py +47 -47
  14. not1mm/plugins/arrl_dx_ssb.py +48 -48
  15. not1mm/plugins/canada_day.py +6 -6
  16. not1mm/plugins/cq_160_cw.py +16 -16
  17. not1mm/plugins/cq_160_ssb.py +16 -16
  18. not1mm/plugins/cq_wpx_cw.py +28 -28
  19. not1mm/plugins/cq_wpx_rtty.py +20 -20
  20. not1mm/plugins/cq_wpx_ssb.py +28 -28
  21. not1mm/plugins/cq_ww_cw.py +19 -19
  22. not1mm/plugins/cq_ww_rtty.py +14 -14
  23. not1mm/plugins/cq_ww_ssb.py +18 -18
  24. not1mm/plugins/ea_majistad_cw.py +6 -6
  25. not1mm/plugins/ea_majistad_ssb.py +6 -6
  26. not1mm/plugins/ea_rtty.py +6 -6
  27. not1mm/plugins/es_field_day.py +604 -0
  28. not1mm/plugins/es_open.py +37 -26
  29. not1mm/plugins/helvetia.py +12 -12
  30. not1mm/plugins/iaru_hf.py +3 -3
  31. not1mm/plugins/jidx_cw.py +4 -4
  32. not1mm/plugins/jidx_ph.py +4 -4
  33. not1mm/plugins/lz-dx.py +12 -12
  34. not1mm/plugins/naqp_cw.py +6 -6
  35. not1mm/plugins/naqp_rtty.py +6 -6
  36. not1mm/plugins/naqp_ssb.py +6 -6
  37. not1mm/plugins/phone_weekly_test.py +6 -6
  38. not1mm/plugins/ref_cw.py +8 -8
  39. not1mm/plugins/ref_ssb.py +8 -8
  40. not1mm/plugins/sac_cw.py +9 -9
  41. not1mm/plugins/sac_ssb.py +11 -11
  42. not1mm/plugins/spdx.py +7 -7
  43. not1mm/plugins/ukeidx.py +10 -10
  44. not1mm/statistics.py +1 -0
  45. {not1mm-25.5.26.1.dist-info → not1mm-25.6.1.dist-info}/METADATA +7 -277
  46. {not1mm-25.5.26.1.dist-info → not1mm-25.6.1.dist-info}/RECORD +50 -49
  47. {not1mm-25.5.26.1.dist-info → not1mm-25.6.1.dist-info}/WHEEL +1 -1
  48. {not1mm-25.5.26.1.dist-info → not1mm-25.6.1.dist-info}/entry_points.txt +0 -0
  49. {not1mm-25.5.26.1.dist-info → not1mm-25.6.1.dist-info}/licenses/LICENSE +0 -0
  50. {not1mm-25.5.26.1.dist-info → not1mm-25.6.1.dist-info}/top_level.txt +0 -0
@@ -362,6 +362,11 @@
362
362
  <string>ES OPEN</string>
363
363
  </property>
364
364
  </item>
365
+ <item>
366
+ <property name="text">
367
+ <string>ES FIELD DAY</string>
368
+ </property>
369
+ </item>
365
370
  <item>
366
371
  <property name="text">
367
372
  <string>HELVETIA</string>
not1mm/lib/database.py CHANGED
@@ -1234,77 +1234,45 @@ class DataBase:
1234
1234
  except sqlite3.OperationalError as exception:
1235
1235
  logger.debug("%s", exception)
1236
1236
  return {}
1237
-
1238
- def exec_sql(self, query: str) -> dict:
1237
+
1238
+ def exec_sql_params_mult(self, query: str, params=None) -> dict:
1239
1239
  """Exec one off queries returning one dict"""
1240
1240
  try:
1241
1241
  with sqlite3.connect(self.database) as conn:
1242
1242
  conn.row_factory = self.row_factory
1243
1243
  cursor = conn.cursor()
1244
- cursor.execute(query)
1244
+ cursor.execute(query, params)
1245
1245
  return cursor.fetchone()
1246
1246
  except sqlite3.OperationalError as exception:
1247
1247
  logger.debug("%s", exception)
1248
1248
  return {}
1249
1249
 
1250
- def exec_sql_mult(self, query: str) -> list:
1251
- """Exec one off queries returning list of dicts"""
1250
+ def exec_sql(self, query: str) -> dict:
1251
+ """Exec one off queries returning one dict"""
1252
1252
  try:
1253
1253
  with sqlite3.connect(self.database) as conn:
1254
1254
  conn.row_factory = self.row_factory
1255
1255
  cursor = conn.cursor()
1256
1256
  cursor.execute(query)
1257
- return cursor.fetchall()
1258
- except sqlite3.OperationalError as exception:
1259
- logger.debug("%s", exception)
1260
- return []
1261
-
1262
- def check_dupe_on_period_1_mode(
1263
- self, call, band, mode, contest_start_time, contest_time_period_1
1264
- ) -> dict:
1265
- """Checks if a call is dupe on band/mode"""
1266
- try:
1267
- with sqlite3.connect(self.database) as conn:
1268
- conn.row_factory = self.row_factory
1269
- cursor = conn.cursor()
1270
- cursor.execute(
1271
- f"select count(*) as isdupe from dxlog where Call = '{call}' and Mode = '{mode}' and Band = '{band}' and ContestNR = {self.current_contest} AND TS >= '{contest_start_time}' AND TS <= '{contest_time_period_1}';"
1272
- )
1273
1257
  return cursor.fetchone()
1274
1258
  except sqlite3.OperationalError as exception:
1275
1259
  logger.debug("%s", exception)
1276
1260
  return {}
1277
1261
 
1278
- def check_dupe_on_period_2_mode(
1279
- self,
1280
- call,
1281
- band,
1282
- mode,
1283
- contest_start_time,
1284
- contest_time_period_1,
1285
- contest_time_period_2,
1286
- ) -> dict:
1287
- """Checks if a call is dupe on band/mode"""
1262
+ def exec_sql_mult(self, query: str) -> list:
1263
+ """Exec one off queries returning list of dicts"""
1288
1264
  try:
1289
1265
  with sqlite3.connect(self.database) as conn:
1290
1266
  conn.row_factory = self.row_factory
1291
1267
  cursor = conn.cursor()
1292
- cursor.execute(
1293
- f"select count(*) as isdupe from dxlog where Call = '{call}' and Mode = '{mode}' and Band = '{band}' and ContestNR = {self.current_contest} AND TS >= '{contest_time_period_1}' AND TS <= '{contest_time_period_2}';"
1294
- )
1295
- return cursor.fetchone()
1268
+ cursor.execute(query)
1269
+ return cursor.fetchall()
1296
1270
  except sqlite3.OperationalError as exception:
1297
1271
  logger.debug("%s", exception)
1298
- return {}
1272
+ return []
1299
1273
 
1300
- def check_dupe_on_period_3_mode(
1301
- self,
1302
- call,
1303
- band,
1304
- mode,
1305
- contest_start_time,
1306
- contest_time_period_2,
1307
- contest_time_period_3,
1274
+ def check_dupe_on_period_mode(
1275
+ self, call, band, mode, period_1, period_2
1308
1276
  ) -> dict:
1309
1277
  """Checks if a call is dupe on band/mode"""
1310
1278
  try:
@@ -1312,9 +1280,10 @@ class DataBase:
1312
1280
  conn.row_factory = self.row_factory
1313
1281
  cursor = conn.cursor()
1314
1282
  cursor.execute(
1315
- f"select count(*) as isdupe from dxlog where Call = '{call}' and Mode = '{mode}' and Band = '{band}' and ContestNR = {self.current_contest} AND TS >= '{contest_time_period_2}' AND TS <= '{contest_time_period_3}';"
1283
+ f"select count(*) as isdupe from dxlog where Call = '{call}' and Mode = '{mode}' and Band = '{band}' and ContestNR = {self.current_contest} AND TS >= '{period_1}' AND TS <= '{period_2}';"
1316
1284
  )
1317
1285
  return cursor.fetchone()
1318
1286
  except sqlite3.OperationalError as exception:
1319
1287
  logger.debug("%s", exception)
1320
1288
  return {}
1289
+
@@ -35,11 +35,11 @@ class EditStation(QtWidgets.QDialog):
35
35
  def call_changed(self):
36
36
  """Populate zones"""
37
37
  results = self.cty_lookup()
38
- if results:
39
- for result in results.items():
40
- self.CQZone.setText(str(result[1].get("cq", "")))
41
- self.ITUZone.setText(str(result[1].get("itu", "")))
42
- self.Country.setText(str(result[1].get("entity", "")))
38
+ if results is not None:
39
+ result = results.get(next(iter(results)))
40
+ self.CQZone.setText(str(result.get("cq", "")))
41
+ self.ITUZone.setText(str(result.get("itu", "")))
42
+ self.Country.setText(str(result.get("entity", "")))
43
43
 
44
44
  def cty_lookup(self):
45
45
  """Lookup callsign in cty.dat file"""
@@ -336,3 +336,24 @@ def gen_adif(self, cabrillo_name: str, contest_id=""):
336
336
  self.show_message_box(f"ADIF saved to: {filename}")
337
337
  except IOError as error:
338
338
  self.show_message_box(f"Error saving ADIF file: {error}")
339
+
340
+
341
+ def get_station_arrlsection_code(self):
342
+ # get the station ARRL Section in station settings
343
+ query = f"SELECT ARRLSection as arrlsection from Station;"
344
+ # run query
345
+ result = self.database.exec_sql(query)
346
+ if result:
347
+ arrlsection = result.get("arrlsection", "")
348
+ return arrlsection
349
+ return ""
350
+
351
+ def get_station_state_code(self):
352
+ # get the station state code in station settings
353
+ query = f"SELECT state as state from Station;"
354
+ # run query
355
+ result = self.database.exec_sql(query)
356
+ if result:
357
+ state = result.get("state", "")
358
+ return state
359
+ return ""
@@ -10,6 +10,8 @@ import requests
10
10
  from rapidfuzz import fuzz
11
11
  from rapidfuzz import process
12
12
 
13
+ from functools import lru_cache
14
+
13
15
  MASTER_SCP_URL = "https://www.supercheckpartial.com/MASTER.SCP"
14
16
 
15
17
  if __name__ == "__main__":
@@ -27,6 +29,15 @@ def prefer_prefix_score(query: str, candidate: str, **kwargs) -> int:
27
29
  score = 0.8 * score
28
30
  return int(round(score))
29
31
 
32
+ @lru_cache(maxsize=1024) # You can adjust this as needed
33
+ def prefix_bias_score(query: str, candidate: str, **kwargs) -> int:
34
+ """Return a score based on the quality of the match."""
35
+ score = fuzz.QRatio(query, candidate)
36
+
37
+ if candidate[:len(query)] == query:
38
+ return score
39
+ return int(score*0.8)
40
+
30
41
 
31
42
  class SCP:
32
43
  """Super check partial"""
@@ -53,7 +64,7 @@ class SCP:
53
64
  def read_scp(self):
54
65
  """
55
66
  Reads in a list of known contesters into an internal dictionary
56
- """
67
+ """
57
68
  try:
58
69
  with open(
59
70
  Path(self.app_data_path) / "MASTER.SCP", "r", encoding="utf-8"
@@ -63,17 +74,22 @@ class SCP:
63
74
  except IOError as exception:
64
75
  logger.critical("read_scp: read error: %s", exception)
65
76
 
77
+
66
78
  def super_check(self, acall: str) -> list:
67
- """
68
- Performs a supercheck partial on the callsign entered in the field.
69
- """
79
+
70
80
  if len(acall) > 1:
71
- return list(
72
- [
73
- x[0]
74
- for x in process.extract(
75
- acall, self.scp, scorer=prefer_prefix_score, limit=20
76
- )
77
- ]
81
+ # Compute similarity scores between `acall` and all items in `self.scp`
82
+ similarity_scores = process.cdist(
83
+ [acall], self.scp, scorer=prefix_bias_score, workers=-1,score_cutoff=60
78
84
  )
79
- return []
85
+
86
+ # Sort and retrieve the top 20 matches with their indices
87
+ top_matches = sorted(
88
+ enumerate(similarity_scores[0]), key=lambda x: -x[1]
89
+ )[:20]
90
+
91
+ # Extract the corresponding strings from `self.scp`
92
+ matches = [self.scp[idx] for idx, score in top_matches if score > 0]
93
+
94
+ return matches
95
+ return []
not1mm/lib/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """It's the version"""
2
2
 
3
- __version__ = "25.5.26.1"
3
+ __version__ = "25.6.1"
not1mm/logwindow.py CHANGED
@@ -112,6 +112,8 @@ class LogWindow(QDockWidget):
112
112
  self.setWindowTitle(
113
113
  f"QSO History - {self.pref.get('current_database', 'ham.db')}"
114
114
  )
115
+ self.generalLog.setAlternatingRowColors(True)
116
+ self.focusedLog.setAlternatingRowColors(True)
115
117
  self.generalLog.setColumnCount(len(self.columns))
116
118
  self.focusedLog.setColumnCount(len(self.columns))
117
119
 
@@ -1064,6 +1066,8 @@ class LogWindow(QDockWidget):
1064
1066
  self.get_column("UUID"),
1065
1067
  QtWidgets.QTableWidgetItem(str(log_item.get("ID", ""))),
1066
1068
  )
1069
+ self.focusedLog.resizeColumnsToContents()
1070
+ self.focusedLog.resizeRowsToContents()
1067
1071
  self.focusedLog.blockSignals(False)
1068
1072
 
1069
1073
  def show_message_box(self, message: str) -> None:
not1mm/plugins/ari_dx.py CHANGED
@@ -156,19 +156,19 @@ def points(self) -> int:
156
156
  return 0
157
157
 
158
158
  result = self.cty_lookup(self.station.get("Call", ""))
159
- if result:
160
- for item in result.items():
161
- mycountry = item[1].get("primary_pfx", "")
162
- # myentity = item[1].get("entity", "")
163
- mycontinent = item[1].get("continent", "")
159
+ if result is not None:
160
+ item = result.get(next(iter(result)))
161
+ mycountry = item.get("primary_pfx", "")
162
+ # myentity = item.get("entity", "")
163
+ mycontinent = item.get("continent", "")
164
164
 
165
165
  result = self.cty_lookup(self.contact.get("Call", ""))
166
-
167
- if result:
168
- for item in result.items():
169
- hiscountry = item[1].get("primary_pfx", "")
170
- # hisentity = item[1].get("entity", "")
171
- hiscontinent = item[1].get("continent", "")
166
+ print(f"{result=}")
167
+ if result is not None:
168
+ item = result.get(next(iter(result)))
169
+ hiscountry = item.get("primary_pfx", "")
170
+ # hisentity = item.get("entity", "")
171
+ hiscontinent = item.get("continent", "")
172
172
 
173
173
  _points = 0
174
174
 
@@ -112,18 +112,18 @@ def points(self):
112
112
  if dupe_check.get("isdupe", 0) > 0:
113
113
  return 0
114
114
  result = self.cty_lookup(self.station.get("Call", ""))
115
- if result:
116
- for item in result.items():
117
- mypfx = item[1].get("primary_pfx", "")
118
- # mycountry = item[1].get("entity", "")
119
- # mycontinent = item[1].get("continent", "")
115
+ if result is not None:
116
+ item = result.get(next(iter(result)))
117
+ mypfx = item.get("primary_pfx", "")
118
+ # mycountry = item[1].get("entity", "")
119
+ # mycontinent = item[1].get("continent", "")
120
120
 
121
121
  result = self.cty_lookup(self.contact.get("Call", ""))
122
- if result:
123
- for item in result.items():
124
- pfx = item[1].get("primary_pfx", "")
125
- # entity = item[1].get("entity", "")
126
- # continent = item[1].get("continent", "")
122
+ if result is not None:
123
+ item = result.get(next(iter(result)))
124
+ pfx = item.get("primary_pfx", "")
125
+ # entity = item[1].get("entity", "")
126
+ # continent = item[1].get("continent", "")
127
127
 
128
128
  # Both in same country
129
129
 
@@ -221,10 +221,10 @@ def calc_score(self):
221
221
  def can_claim_dxcc(self):
222
222
  """"""
223
223
  result = self.cty_lookup(self.station.get("Call", ""))
224
- if result:
224
+ if result is not None:
225
225
  mypfx = ""
226
- for item in result.items():
227
- mypfx = item[1].get("primary_pfx", "")
226
+ item = result.get(next(iter(result)))
227
+ mypfx = item.get("primary_pfx", "")
228
228
  if mypfx in [
229
229
  "K",
230
230
  "KL",
@@ -103,14 +103,14 @@ def prefill(self):
103
103
  # self.other_2.setText(str(self.contact.get("ZN", "")))
104
104
  self.other_1.setText(str(self.contest_settings.get("SentExchange", 0)))
105
105
 
106
- location = self.cty_lookup(self.station.get("Call", ""))
107
- if location:
108
- for item in location.items():
109
- mycountry = item[1].get("primary_pfx", "")
110
- if mycountry in ["K", "VE"]:
111
- query = f"select count(*) as prefix_count from dxlog where Band={float(self.contact.get('Band', 0))} and CountryPrefix='{self.contact.get('CountryPrefix','')}' and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
112
- else:
113
- query = f"select count(*) as prefix_count from dxlog where Band={float(self.contact.get('Band', 0))} and NR='{self.contact.get('NR','')}' and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
106
+ result = self.cty_lookup(self.station.get("Call", ""))
107
+ if result is not None:
108
+ item = result.get(next(iter(result)))
109
+ mycountry = item.get("primary_pfx", "")
110
+ if mycountry in ["K", "VE"]:
111
+ query = f"select count(*) as prefix_count from dxlog where Band={float(self.contact.get('Band', 0))} and CountryPrefix='{self.contact.get('CountryPrefix','')}' and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
112
+ else:
113
+ query = f"select count(*) as prefix_count from dxlog where Band={float(self.contact.get('Band', 0))} and NR='{self.contact.get('NR','')}' and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
114
114
 
115
115
  result = self.database.exec_sql(query)
116
116
  count = result.get("prefix_count", 0)
@@ -127,20 +127,20 @@ def points(self):
127
127
  return 0
128
128
 
129
129
  result = self.cty_lookup(self.station.get("Call", ""))
130
- if result:
131
- for item in result.items():
132
- mycountry = item[1].get("primary_pfx", "")
130
+ if result is not None:
131
+ item = result.get(next(iter(result)))
132
+ mycountry = item.get("primary_pfx", "")
133
133
  result = self.cty_lookup(self.contact.get("Call", ""))
134
- if result:
135
- for item in result.items():
136
- entity = item[1].get("primary_pfx", "")
137
- if mycountry in ["K", "VE"]:
138
- if entity in ["K", "VE"]:
139
- return 0
140
- return 3
134
+ if result is not None:
135
+ item = result.get(next(iter(result)))
136
+ entity = item.get("primary_pfx", "")
137
+ if mycountry in ["K", "VE"]:
141
138
  if entity in ["K", "VE"]:
142
- return 3
143
- return 0
139
+ return 0
140
+ return 3
141
+ if entity in ["K", "VE"]:
142
+ return 3
143
+ return 0
144
144
  return 0
145
145
 
146
146
 
@@ -148,17 +148,17 @@ def show_mults(self, rtc=None):
148
148
  """Return display string for mults"""
149
149
  location = self.cty_lookup(self.station.get("Call", ""))
150
150
  _country, _state = 0, 0
151
- if location:
152
- for item in location.items():
153
- mycountry = item[1].get("primary_pfx", "")
154
- if mycountry in ["K", "VE"]:
155
- result = self.database.fetch_arrldx_country_band_count()
156
- if result:
157
- _country = int(result.get("cb_count", 0))
158
- else:
159
- result = self.database.fetch_arrldx_state_prov_count()
160
- if result:
161
- _state = int(result.get("cb_count", 0))
151
+ if location is not None:
152
+ item = location.get(next(iter(location)))
153
+ mycountry = item.get("primary_pfx", "")
154
+ if mycountry in ["K", "VE"]:
155
+ result = self.database.fetch_arrldx_country_band_count()
156
+ if result:
157
+ _country = int(result.get("cb_count", 0))
158
+ else:
159
+ result = self.database.fetch_arrldx_state_prov_count()
160
+ if result:
161
+ _state = int(result.get("cb_count", 0))
162
162
  if rtc is not None:
163
163
  return (_country, _state)
164
164
  return _country + _state
@@ -400,23 +400,23 @@ def recalculate_mults(self):
400
400
 
401
401
  for contact in all_contacts:
402
402
  time_stamp = contact.get("TS", "")
403
- entity = contact.get("CountryPrefix", "")
403
+ # entity = contact.get("CountryPrefix", "")
404
404
  location = self.cty_lookup(self.station.get("Call", ""))
405
- if location:
406
- for item in location.items():
407
- mycountry = item[1].get("primary_pfx", "")
408
- if mycountry in ["K", "VE"]:
409
- query = (
410
- f"select count(*) as prefix_count from dxlog where TS < '{time_stamp}' "
411
- f"and CountryPrefix='{contact.get('CountryPrefix','')}' "
412
- f"and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
413
- )
414
- else:
415
- query = (
416
- f"select count(*) as prefix_count from dxlog where TS < '{time_stamp}' "
417
- f"and NR='{contact.get('NR','')}' "
418
- f"and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
419
- )
405
+ if location is not None:
406
+ item = location.get(next(iter(location)))
407
+ mycountry = item.get("primary_pfx", "")
408
+ if mycountry in ["K", "VE"]:
409
+ query = (
410
+ f"select count(*) as prefix_count from dxlog where TS < '{time_stamp}' "
411
+ f"and CountryPrefix='{contact.get('CountryPrefix','')}' "
412
+ f"and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
413
+ )
414
+ else:
415
+ query = (
416
+ f"select count(*) as prefix_count from dxlog where TS < '{time_stamp}' "
417
+ f"and NR='{contact.get('NR','')}' "
418
+ f"and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
419
+ )
420
420
  result = self.database.exec_sql(query)
421
421
  logger.debug("contact: %s", contact)
422
422
  logger.debug("query: %s", query)
@@ -103,14 +103,14 @@ def prefill(self):
103
103
  # self.other_2.setText(str(self.contact.get("ZN", "")))
104
104
  self.other_1.setText(str(self.contest_settings.get("SentExchange", 0)))
105
105
 
106
- location = self.cty_lookup(self.station.get("Call", ""))
107
- if location:
108
- for item in location.items():
109
- mycountry = item[1].get("primary_pfx", "")
110
- if mycountry in ["K", "VE"]:
111
- query = f"select count(*) as prefix_count from dxlog where Band={float(self.contact.get('Band', 0))} and CountryPrefix='{self.contact.get('CountryPrefix','')}' and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
112
- else:
113
- query = f"select count(*) as prefix_count from dxlog where Band={float(self.contact.get('Band', 0))} and NR='{self.contact.get('NR','')}' and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
106
+ result = self.cty_lookup(self.station.get("Call", ""))
107
+ if result is not None:
108
+ item = result.get(next(iter(result)))
109
+ mycountry = item.get("primary_pfx", "")
110
+ if mycountry in ["K", "VE"]:
111
+ query = f"select count(*) as prefix_count from dxlog where Band={float(self.contact.get('Band', 0))} and CountryPrefix='{self.contact.get('CountryPrefix','')}' and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
112
+ else:
113
+ query = f"select count(*) as prefix_count from dxlog where Band={float(self.contact.get('Band', 0))} and NR='{self.contact.get('NR','')}' and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
114
114
 
115
115
  result = self.database.exec_sql(query)
116
116
  count = result.get("prefix_count", 0)
@@ -127,38 +127,38 @@ def points(self):
127
127
  return 0
128
128
 
129
129
  result = self.cty_lookup(self.station.get("Call", ""))
130
- if result:
131
- for item in result.items():
132
- mycountry = item[1].get("primary_pfx", "")
130
+ if result is not None:
131
+ item = result.get(next(iter(result)))
132
+ mycountry = item.get("primary_pfx", "")
133
133
  result = self.cty_lookup(self.contact.get("Call", ""))
134
- if result:
135
- for item in result.items():
136
- entity = item[1].get("primary_pfx", "")
137
- if mycountry in ["K", "VE"]:
138
- if entity in ["K", "VE"]:
139
- return 0
140
- return 3
134
+ if result is not None:
135
+ item = result.get(next(iter(result)))
136
+ entity = item.get("primary_pfx", "")
137
+ if mycountry in ["K", "VE"]:
141
138
  if entity in ["K", "VE"]:
142
- return 3
143
- return 0
139
+ return 0
140
+ return 3
141
+ if entity in ["K", "VE"]:
142
+ return 3
143
+ return 0
144
144
  return 0
145
145
 
146
146
 
147
147
  def show_mults(self, rtc=None):
148
148
  """Return display string for mults"""
149
- location = self.cty_lookup(self.station.get("Call", ""))
149
+ result = self.cty_lookup(self.station.get("Call", ""))
150
150
  _country, _state = 0, 0
151
- if location:
152
- for item in location.items():
153
- mycountry = item[1].get("primary_pfx", "")
154
- if mycountry in ["K", "VE"]:
155
- result = self.database.fetch_arrldx_country_band_count()
156
- if result:
157
- _country = int(result.get("cb_count", 0))
158
- else:
159
- result = self.database.fetch_arrldx_state_prov_count()
160
- if result:
161
- _state = int(result.get("cb_count", 0))
151
+ if result is not None:
152
+ item = result.get(next(iter(result)))
153
+ mycountry = item.get("primary_pfx", "")
154
+ if mycountry in ["K", "VE"]:
155
+ result = self.database.fetch_arrldx_country_band_count()
156
+ if result:
157
+ _country = int(result.get("cb_count", 0))
158
+ else:
159
+ result = self.database.fetch_arrldx_state_prov_count()
160
+ if result:
161
+ _state = int(result.get("cb_count", 0))
162
162
  if rtc is not None:
163
163
  return (_country, _state)
164
164
  return _country + _state
@@ -399,23 +399,23 @@ def recalculate_mults(self):
399
399
  all_contacts = self.database.fetch_all_contacts_asc()
400
400
  for contact in all_contacts:
401
401
  time_stamp = contact.get("TS", "")
402
- entity = contact.get("CountryPrefix", "")
402
+ # entity = contact.get("CountryPrefix", "")
403
403
  location = self.cty_lookup(self.station.get("Call", ""))
404
- if location:
405
- for item in location.items():
406
- mycountry = item[1].get("primary_pfx", "")
407
- if mycountry in ["K", "VE"]:
408
- query = (
409
- f"select count(*) as prefix_count from dxlog where TS < '{time_stamp}' "
410
- f"and CountryPrefix='{contact.get('CountryPrefix','')}' "
411
- f"and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
412
- )
413
- else:
414
- query = (
415
- f"select count(*) as prefix_count from dxlog where TS < '{time_stamp}' "
416
- f"and NR='{contact.get('NR','')}' "
417
- f"and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
418
- )
404
+ if location is not None:
405
+ item = location.get(next(iter(location)))
406
+ mycountry = item.get("primary_pfx", "")
407
+ if mycountry in ["K", "VE"]:
408
+ query = (
409
+ f"select count(*) as prefix_count from dxlog where TS < '{time_stamp}' "
410
+ f"and CountryPrefix='{contact.get('CountryPrefix','')}' "
411
+ f"and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
412
+ )
413
+ else:
414
+ query = (
415
+ f"select count(*) as prefix_count from dxlog where TS < '{time_stamp}' "
416
+ f"and NR='{contact.get('NR','')}' "
417
+ f"and ContestNR = {self.pref.get('contest', '1')} and points = 3;"
418
+ )
419
419
  result = self.database.exec_sql(query)
420
420
  logger.debug("contact: %s", contact)
421
421
  logger.debug("query: %s", query)
@@ -159,12 +159,12 @@ def points(self):
159
159
  return 20
160
160
 
161
161
  result = self.cty_lookup(self.contact.get("Call", ""))
162
- if result:
163
- for item in result.items():
164
- entity = item[1].get("entity", "")
165
- # continent = item[1].get("continent", "")
166
- if entity == "Canada":
167
- return 10
162
+ if result is not None:
163
+ item = result.get(next(iter(result)))
164
+ entity = item.get("entity", "")
165
+ # continent = item[1].get("continent", "")
166
+ if entity == "Canada":
167
+ return 10
168
168
 
169
169
  return 2
170
170
 
@@ -142,26 +142,26 @@ def points(self):
142
142
  return 5
143
143
 
144
144
  result = self.cty_lookup(self.station.get("Call", ""))
145
- if result:
146
- for item in result.items():
147
- mycountry = item[1].get("entity", "")
148
- mycontinent = item[1].get("continent", "")
145
+ if result is not None:
146
+ item = result.get(next(iter(result)))
147
+ mycountry = item.get("entity", "")
148
+ mycontinent = item.get("continent", "")
149
149
  result = self.cty_lookup(self.contact.get("Call", ""))
150
- if result:
151
- for item in result.items():
152
- entity = item[1].get("entity", "")
153
- continent = item[1].get("continent", "")
150
+ if result is not None:
151
+ item = result.get(next(iter(result)))
152
+ entity = item.get("entity", "")
153
+ continent = item.get("continent", "")
154
154
 
155
- # Both in same country
156
- if mycountry.upper() == entity.upper():
157
- return 2
155
+ # Both in same country
156
+ if mycountry.upper() == entity.upper():
157
+ return 2
158
158
 
159
- # Same Continent
160
- if mycontinent == continent:
161
- return 5
159
+ # Same Continent
160
+ if mycontinent == continent:
161
+ return 5
162
162
 
163
- # Different Continent
164
- return 10
163
+ # Different Continent
164
+ return 10
165
165
  return 0
166
166
 
167
167