Fix icon and ref_type disappearing from SIG Ref lookups

This commit is contained in:
Ian Renton
2026-09-05 10:14:37 +01:00
parent df724409a5
commit 237cdaa091
9 changed files with 24 additions and 25 deletions
+9 -10
View File
@@ -29,14 +29,11 @@ def get_sig_ref_info(sig_name, ref_id):
# Prepare the object to be returned
sig_ref = SIGRef(sig=sig_name, id=ref_id)
# We can always get the reference type and the icon from the SIG itself, if the reference data doesn't already
# contain it. If the sig ref already has this data, it should be used for preference.
# We can always get the reference type and the icon from the SIG itself
for sig in SIGS:
if sig.name.upper() == sig_name.upper():
if not sig_ref.ref_type:
sig_ref.ref_type = sig.ref_type
if not sig_ref.icon:
sig_ref.icon = sig.icon
sig_ref.ref_type = sig.ref_type
sig_ref.icon = sig.icon
try:
### FUDGES ###
@@ -45,7 +42,7 @@ def get_sig_ref_info(sig_name, ref_id):
# activators add leading zeros. We also need to normalise "DME 01234" to "DME-01234" to match what's in our
# database.
if sig_name.upper() == "DME":
match = re.match(r"DME[\- ]\d{3,5}", ref_id, re.IGNORECASE)
match = re.match(r"DME[\- ](\d{3,5})", ref_id, re.IGNORECASE)
number = match.group(1)
return f"DME-{number.zfill(5)}"
@@ -113,12 +110,14 @@ def get_sig_ref_info(sig_name, ref_id):
### ACTUAL LOOKUP ###
#
# OK, this is something we have to look up. Now check to see if our data store contains reference data and use
# that.
# OK, this is something we have to look up. Now check to see if our data store contains reference data and if
# so, copy the data into the sig_ref object
key = f"{sig_name}:{ref_id}"
lookup_data = DATA_STORE.sigrefs.get(key) if key in DATA_STORE.sigrefs else None
if lookup_data:
return lookup_data
for key, value in lookup_data.__dict__.items():
if value is not None and sig_ref.__dict__.get(key) is None:
sig_ref.__dict__[key] = value
else:
# Maybe a super new reference we don't know about yet, but more likely a typo or a test reference,