Replace the wildcards in a given message.
39def replaceWildcards(message, bwPacket):
40 r"""!Replace the wildcards in a given message
41
42 @param message: Message in which wildcards should be replaced
43 @param bwPacket: bwPacket instance with the replacement information
44 @return Input message with the replaced wildcards"""
45 _wildcards = {
46
47
48 "{BR}": "\r\n",
49 "{LPAR}": "(",
50 "{RPAR}": ")",
51 "{TIME}": time.strftime("%d.%m.%Y %H:%M:%S"),
52
53
54
55 "{SNAME}": bwPacket.get("serverName"),
56 "{SVERS}": bwPacket.get("serverVersion"),
57 "{SDATE}": bwPacket.get("serverBuildDate"),
58 "{SBRCH}": bwPacket.get("serverBranch"),
59
60
61 "{CNAME}": bwPacket.get("clientName"),
62 "{CIP}": bwPacket.get("clientIP"),
63 "{CVERS}": bwPacket.get("clientVersion"),
64 "{CDATE}": bwPacket.get("clientBuildDate"),
65 "{CBRCH}": bwPacket.get("clientBranch"),
66
67
68 "{INSRC}": bwPacket.get("inputSource"),
69 "{TIMES}": bwPacket.get("timestamp"),
70 "{FREQ}": bwPacket.get("frequency"),
71 "{MODE}": bwPacket.get("mode"),
72
73
74 "{FMS}": bwPacket.get("fms"),
75 "{SERV}": bwPacket.get("service"),
76 "{COUNT}": bwPacket.get("country"),
77 "{LOC}": bwPacket.get("location"),
78 "{VEHC}": bwPacket.get("vehicle"),
79 "{STAT}": bwPacket.get("status"),
80 "{DIR}": bwPacket.get("direction"),
81 "{DIRT}": bwPacket.get("directionText"),
82 "{TACI}": bwPacket.get("tacticalInfo"),
83
84
85 "{BIT}": bwPacket.get("bitrate"),
86 "{RIC}": bwPacket.get("ric"),
87 "{SRIC}": bwPacket.get("subric"),
88 "{SRICT}": bwPacket.get("subricText"),
89 "{MSG}": bwPacket.get("message"),
90
91
92 "{TONE}": bwPacket.get("tone"),
93
94
95 }
96 for wildcard, field in _wildcards.items():
97 if field is not None:
98 message = message.replace(wildcard, field)
99
100 for wildcard, fieldName in _additionalWildcards.items():
101 field = bwPacket.get(fieldName)
102 if field is not None:
103 message = message.replace(wildcard, field)
104
105 return message