not1mm 25.5.26__py3-none-any.whl → 25.5.31__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 (46) hide show
  1. not1mm/__main__.py +66 -43
  2. not1mm/data/MASTER.SCP +2636 -2654
  3. not1mm/data/new_contest.ui +5 -0
  4. not1mm/lib/database.py +14 -45
  5. not1mm/lib/edit_station.py +5 -5
  6. not1mm/lib/super_check_partial.py +28 -12
  7. not1mm/lib/version.py +1 -2
  8. not1mm/plugins/ari_dx.py +145 -14
  9. not1mm/plugins/arrl_160m.py +13 -13
  10. not1mm/plugins/arrl_dx_cw.py +47 -47
  11. not1mm/plugins/arrl_dx_ssb.py +48 -48
  12. not1mm/plugins/canada_day.py +6 -6
  13. not1mm/plugins/cq_160_cw.py +16 -16
  14. not1mm/plugins/cq_160_ssb.py +16 -16
  15. not1mm/plugins/cq_wpx_cw.py +28 -28
  16. not1mm/plugins/cq_wpx_rtty.py +20 -20
  17. not1mm/plugins/cq_wpx_ssb.py +28 -28
  18. not1mm/plugins/cq_ww_cw.py +19 -19
  19. not1mm/plugins/cq_ww_rtty.py +14 -14
  20. not1mm/plugins/cq_ww_ssb.py +18 -18
  21. not1mm/plugins/ea_majistad_cw.py +6 -6
  22. not1mm/plugins/ea_majistad_ssb.py +6 -6
  23. not1mm/plugins/ea_rtty.py +6 -6
  24. not1mm/plugins/es_field_day.py +617 -0
  25. not1mm/plugins/es_open.py +37 -26
  26. not1mm/plugins/helvetia.py +12 -12
  27. not1mm/plugins/iaru_hf.py +3 -3
  28. not1mm/plugins/jidx_cw.py +4 -4
  29. not1mm/plugins/jidx_ph.py +4 -4
  30. not1mm/plugins/lz-dx.py +12 -12
  31. not1mm/plugins/naqp_cw.py +6 -6
  32. not1mm/plugins/naqp_rtty.py +6 -6
  33. not1mm/plugins/naqp_ssb.py +6 -6
  34. not1mm/plugins/phone_weekly_test.py +6 -6
  35. not1mm/plugins/ref_cw.py +8 -8
  36. not1mm/plugins/ref_ssb.py +8 -8
  37. not1mm/plugins/sac_cw.py +9 -9
  38. not1mm/plugins/sac_ssb.py +11 -11
  39. not1mm/plugins/spdx.py +7 -7
  40. not1mm/plugins/ukeidx.py +10 -10
  41. {not1mm-25.5.26.dist-info → not1mm-25.5.31.dist-info}/METADATA +7 -266
  42. {not1mm-25.5.26.dist-info → not1mm-25.5.31.dist-info}/RECORD +46 -45
  43. {not1mm-25.5.26.dist-info → not1mm-25.5.31.dist-info}/WHEEL +1 -1
  44. {not1mm-25.5.26.dist-info → not1mm-25.5.31.dist-info}/entry_points.txt +0 -0
  45. {not1mm-25.5.26.dist-info → not1mm-25.5.31.dist-info}/licenses/LICENSE +0 -0
  46. {not1mm-25.5.26.dist-info → not1mm-25.5.31.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"""
@@ -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,4 +1,3 @@
1
1
  """It's the version"""
2
2
 
3
- __version__ = "25.5.26"
4
-
3
+ __version__ = "25.5.31"
not1mm/plugins/ari_dx.py CHANGED
@@ -1,5 +1,11 @@
1
1
  """ARI International DX Contest"""
2
2
 
3
+ # pylint: disable=invalid-name, c-extension-no-member, unused-import, line-too-long
4
+ # pyright: ignore[reportUndefinedVariable]
5
+ # pylance: disable=reportUndefinedVariable
6
+ # ruff: noqa: F821
7
+ # ruff: noqa: F401
8
+
3
9
  # Status: Active
4
10
  # Geographic Focus: Worldwide
5
11
  # Participation: Worldwide
@@ -30,8 +36,6 @@
30
36
  # Cabrillo name: ARI-DX
31
37
 
32
38
 
33
- # pylint: disable=invalid-name, c-extension-no-member, unused-import, line-too-long
34
-
35
39
  import datetime
36
40
  import logging
37
41
  import platform
@@ -40,6 +44,7 @@ from pathlib import Path
40
44
 
41
45
  from PyQt6 import QtWidgets
42
46
 
47
+ from not1mm.lib.ham_utility import get_logged_band
43
48
  from not1mm.lib.plugin_common import gen_adif
44
49
  from not1mm.lib.version import __version__
45
50
 
@@ -151,19 +156,19 @@ def points(self) -> int:
151
156
  return 0
152
157
 
153
158
  result = self.cty_lookup(self.station.get("Call", ""))
154
- if result:
155
- for item in result.items():
156
- mycountry = item[1].get("primary_pfx", "")
157
- myentity = item[1].get("entity", "")
158
- 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", "")
159
164
 
160
165
  result = self.cty_lookup(self.contact.get("Call", ""))
161
-
162
- if result:
163
- for item in result.items():
164
- hiscountry = item[1].get("primary_pfx", "")
165
- hisentity = item[1].get("entity", "")
166
- 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", "")
167
172
 
168
173
  _points = 0
169
174
 
@@ -425,7 +430,7 @@ def cabrillo(self, file_encoding):
425
430
  f"{str(contact.get('SentNr', '')).upper().ljust(6)} "
426
431
  f"{contact.get('Call', '').ljust(13)} "
427
432
  f"{str(contact.get('RCV', '')).ljust(3)} "
428
- f"{str(contact.get('Exchange1', '')).upper().ljust(6)}",
433
+ f"{str(contact.get('NR', '')).upper().ljust(6)}",
429
434
  "\r\n",
430
435
  file_descriptor,
431
436
  file_encoding,
@@ -556,3 +561,129 @@ def check_call_history(self):
556
561
  self.history_info.setText(f"{result.get('UserText','')}")
557
562
  if self.other_2.text() == "":
558
563
  self.other_2.setText(f"{result.get('Sect', '')}")
564
+
565
+
566
+ def set_self(the_outie):
567
+ """..."""
568
+ globals()["ALTEREGO"] = the_outie
569
+
570
+
571
+ def ft8_handler(the_packet: dict):
572
+ print(f"{the_packet=}")
573
+ """Process FT8 QSO packets
574
+ FT8
575
+ {
576
+ 'CALL': 'KE0OG',
577
+ 'GRIDSQUARE': 'DM10AT',
578
+ 'MODE': 'FT8',
579
+ 'RST_SENT': '',
580
+ 'RST_RCVD': '',
581
+ 'QSO_DATE': '20210329',
582
+ 'TIME_ON': '183213',
583
+ 'QSO_DATE_OFF': '20210329',
584
+ 'TIME_OFF': '183213',
585
+ 'BAND': '20M',
586
+ 'FREQ': '14.074754',
587
+ 'STATION_CALLSIGN': 'K6GTE',
588
+ 'MY_GRIDSQUARE': 'DM13AT',
589
+ 'CONTEST_ID': 'ARRL-FIELD-DAY',
590
+ 'SRX_STRING': '1D UT',
591
+ 'CLASS': '1D',
592
+ 'ARRL_SECT': 'UT'
593
+ }
594
+ FlDigi
595
+ {
596
+ 'CALL': 'K5TUS',
597
+ 'MODE': 'RTTY',
598
+ 'FREQ': '14.068415',
599
+ 'BAND': '20M',
600
+ 'QSO_DATE': '20250103',
601
+ 'TIME_ON': '2359',
602
+ 'QSO_DATE_OFF': '20250103',
603
+ 'TIME_OFF': '2359',
604
+ 'NAME': '',
605
+ 'QTH': '',
606
+ 'STATE': 'ORG',
607
+ 'VE_PROV': '',
608
+ 'COUNTRY': 'USA',
609
+ 'RST_SENT': '599',
610
+ 'RST_RCVD': '599',
611
+ 'TX_PWR': '0',
612
+ 'CNTY': '',
613
+ 'DXCC': '',
614
+ 'CQZ': '5',
615
+ 'IOTA': '',
616
+ 'CONT': '',
617
+ 'ITUZ': '',
618
+ 'GRIDSQUARE': '',
619
+ 'QSLRDATE': '',
620
+ 'QSLSDATE': '',
621
+ 'EQSLRDATE': '',
622
+ 'EQSLSDATE': '',
623
+ 'LOTWRDATE': '',
624
+ 'LOTWSDATE': '',
625
+ 'QSL_VIA': '',
626
+ 'NOTES': '',
627
+ 'SRX': '',
628
+ 'STX': '000',
629
+ 'SRX_STRING': '',
630
+ 'STX_STRING': 'CA',
631
+
632
+
633
+ 'SRX': '666',
634
+ 'STX': '000',
635
+ 'SRX_STRING': '',
636
+ 'STX_STRING': 'CA',
637
+
638
+ 'SRX': '004', 'STX': '000', 'SRX_STRING': '', 'STX_STRING': '#',
639
+
640
+ 'CLASS': '',
641
+ 'ARRL_SECT': '',
642
+ 'OPERATOR': 'K6GTE',
643
+ 'STATION_CALLSIGN': 'K6GTE',
644
+ 'MY_GRIDSQUARE': 'DM13AT',
645
+ 'MY_CITY': 'ANAHEIM, CA',
646
+ 'CHECK': '',
647
+ 'AGE': '',
648
+ 'TEN_TEN': '',
649
+ 'CWSS_PREC': '',
650
+ 'CWSS_SECTION': '',
651
+ 'CWSS_SERNO': '',
652
+ 'CWSS_CHK': ''
653
+ }
654
+
655
+ """
656
+ logger.debug(f"{the_packet=}")
657
+ if ALTEREGO is not None: # type: ignore
658
+ ALTEREGO.callsign.setText(the_packet.get("CALL")) # type: ignore
659
+ ALTEREGO.contact["Call"] = the_packet.get("CALL", "") # type: ignore
660
+ ALTEREGO.contact["SNT"] = the_packet.get("RST_SENT", "599") # type: ignore
661
+ ALTEREGO.contact["RCV"] = the_packet.get("RST_RCVD", "599") # type: ignore
662
+
663
+ sent_string = the_packet.get("STX_STRING", "")
664
+ if sent_string != "":
665
+ ALTEREGO.contact["SentNr"] = sent_string # type: ignore
666
+ ALTEREGO.other_1.setText(str(sent_string)) # type: ignore
667
+ else:
668
+ ALTEREGO.contact["SentNr"] = the_packet.get("STX", "000") # type: ignore
669
+ ALTEREGO.other_1.setText(str(the_packet.get("STX", "000"))) # type: ignore
670
+
671
+ rx_string = the_packet.get("STATE", "")
672
+ if rx_string != "":
673
+ ALTEREGO.contact["NR"] = rx_string # type: ignore
674
+ ALTEREGO.other_2.setText(str(rx_string)) # type: ignore
675
+ else:
676
+ ALTEREGO.contact["NR"] = the_packet.get("SRX", "000") # type: ignore
677
+ ALTEREGO.other_2.setText(str(the_packet.get("SRX", "000"))) # type: ignore
678
+
679
+ ALTEREGO.contact["Mode"] = the_packet.get("MODE", "ERR") # type: ignore
680
+ ALTEREGO.contact["Freq"] = round(float(the_packet.get("FREQ", "0.0")) * 1000, 2) # type: ignore
681
+ ALTEREGO.contact["QSXFreq"] = round( # type: ignore
682
+ float(the_packet.get("FREQ", "0.0")) * 1000, 2
683
+ )
684
+ ALTEREGO.contact["Band"] = get_logged_band( # type: ignore
685
+ str(int(float(the_packet.get("FREQ", "0.0")) * 1000000))
686
+ )
687
+ logger.debug(f"{ALTEREGO.contact=}") # type: ignore
688
+
689
+ ALTEREGO.save_contact() # type: ignore
@@ -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)