Behebung der WARNING "field not found" im Log Bedingt durch die modeunabhängige Verarbeitung sämtlicher Wildcards warnt das Programm, dass manche Felder nicht verfügbar sind, die in der derzeitigen Auswertung jedoch gar nicht vorhanden sein können (z.B. FMS Felder in ZVEI-Datensatz etc.)

Änderungen:
- Wildcard-Ersetzung in `replaceWildcards()` nach Paketmodus (fms, pocsag, zvei, msg) aufgeteilt
- Unnötige Wildcards werden nun abhängig vom Modus nicht mehr verarbeitet
- `{MSG}` wird nun explizit für den Modus `msg` unterstützt
- Kopfzeile mit aktuellem Änderungsdatum versehen
This commit is contained in:
KoenigMjr 2025-08-04 09:36:09 +02:00
parent 7ae6dfa820
commit f53102d8c8

View file

@ -10,7 +10,7 @@ r"""!
by Bastian Schroll by Bastian Schroll
@file: wildcard.py @file: wildcard.py
@date: 15.01.2018 @date: 23.07.2025
@author: Bastian Schroll @author: Bastian Schroll
@description: Functions to replace wildcards in stings @description: Functions to replace wildcards in stings
""" """
@ -19,8 +19,6 @@ import time
logging.debug("- %s loaded", __name__) logging.debug("- %s loaded", __name__)
# todo check function - write an test
_additionalWildcards = {} _additionalWildcards = {}
@ -42,6 +40,8 @@ def replaceWildcards(message, bwPacket):
@param message: Message in which wildcards should be replaced @param message: Message in which wildcards should be replaced
@param bwPacket: bwPacket instance with the replacement information @param bwPacket: bwPacket instance with the replacement information
@return Input message with the replaced wildcards""" @return Input message with the replaced wildcards"""
# Start with wildcards that are always available
_wildcards = { _wildcards = {
# formatting wildcards # formatting wildcards
# todo check if br and par are needed - if not also change config # todo check if br and par are needed - if not also change config
@ -69,8 +69,14 @@ def replaceWildcards(message, bwPacket):
"{TIMES}": bwPacket.get("timestamp"), "{TIMES}": bwPacket.get("timestamp"),
"{FREQ}": bwPacket.get("frequency"), "{FREQ}": bwPacket.get("frequency"),
"{MODE}": bwPacket.get("mode"), "{MODE}": bwPacket.get("mode"),
}
# Get the packet mode to add specific wildcards
mode = bwPacket.get("mode")
# fms wildcards # fms wildcards
if mode == "fms":
fms_wildcards = {
"{FMS}": bwPacket.get("fms"), "{FMS}": bwPacket.get("fms"),
"{SERV}": bwPacket.get("service"), "{SERV}": bwPacket.get("service"),
"{COUNT}": bwPacket.get("country"), "{COUNT}": bwPacket.get("country"),
@ -80,23 +86,41 @@ def replaceWildcards(message, bwPacket):
"{DIR}": bwPacket.get("direction"), "{DIR}": bwPacket.get("direction"),
"{DIRT}": bwPacket.get("directionText"), "{DIRT}": bwPacket.get("directionText"),
"{TACI}": bwPacket.get("tacticalInfo"), "{TACI}": bwPacket.get("tacticalInfo"),
}
_wildcards.update(fms_wildcards)
# pocsag wildcards # pocsag wildcards
elif mode == "pocsag":
pocsag_wildcards = {
"{BIT}": bwPacket.get("bitrate"), "{BIT}": bwPacket.get("bitrate"),
"{RIC}": bwPacket.get("ric"), "{RIC}": bwPacket.get("ric"),
"{SRIC}": bwPacket.get("subric"), "{SRIC}": bwPacket.get("subric"),
"{SRICT}": bwPacket.get("subricText"), "{SRICT}": bwPacket.get("subricText"),
"{MSG}": bwPacket.get("message"), "{MSG}": bwPacket.get("message"),
}
_wildcards.update(pocsag_wildcards)
# zvei wildcards # zvei wildcards
elif mode == "zvei":
zvei_wildcards = {
"{TONE}": bwPacket.get("tone"), "{TONE}": bwPacket.get("tone"),
# message for MSG packet is done in poc
} }
_wildcards.update(zvei_wildcards)
# msg wildcards
elif mode == "msg":
msg_wildcards = {
"{MSG}": bwPacket.get("message"),
}
_wildcards.update(msg_wildcards)
# Now, replace all collected wildcards
for wildcard, field in _wildcards.items(): for wildcard, field in _wildcards.items():
# Only replace if the field was found in the packet (is not None)
if field is not None: if field is not None:
message = message.replace(wildcard, field) message = message.replace(wildcard, field)
# Handle additional, dynamically registered wildcards
for wildcard, fieldName in _additionalWildcards.items(): for wildcard, fieldName in _additionalWildcards.items():
field = bwPacket.get(fieldName) field = bwPacket.get(fieldName)
if field is not None: if field is not None: