X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ricxappframe%2Frmr%2Frmrclib%2Frmrclib.py;h=c26ffe1bec94ad720165e6a1aea37c6e84df83a6;hb=2def417a499bb979f7156d3baf52450e8168fbcf;hp=953b76fb71e0462e1d50c83ba9af90a11da11efe;hpb=c4591e61182c2f9b4395df2115769ef6c1dfce91;p=ric-plt%2Fxapp-frame-py.git diff --git a/ricxappframe/rmr/rmrclib/rmrclib.py b/ricxappframe/rmr/rmrclib/rmrclib.py index 953b76f..c26ffe1 100644 --- a/ricxappframe/rmr/rmrclib/rmrclib.py +++ b/ricxappframe/rmr/rmrclib/rmrclib.py @@ -97,9 +97,13 @@ def get_mapping_dict(cache={}): def state_to_status(stateno): """ - Converts a msg state integer to a status string. + Converts a msg state integer to a status string and caches for subsequent calls. Returns "UNKNOWN STATE" if the int value is not known. """ - sdict = get_mapping_dict() - return sdict.get(stateno, "UNKNOWN STATE") + try: + return state_to_status.sdict.get(stateno, "UNKNOWN STATE") + except AttributeError: # sdict does not exist on first call + state_to_status.sdict = get_mapping_dict() + + return state_to_status.sdict.get(stateno, "UNKNOWN STATE")