Looks good. Ack. -----Original Message----- From: Thien Minh Huynh <thien.m.hu...@dektech.com.au> Sent: Thursday, May 2, 2024 1:11 PM To: Thang Duc Nguyen <thang.d.ngu...@dektech.com.au>; Dat Tran Quoc Phan <dat.tq.p...@dektech.com.au> Cc: opensaf-devel@lists.sourceforge.net; Thien Minh Huynh <thien.m.hu...@dektech.com.au> Subject: [PATCH 1/1] pyosaf: Allow SaStringT compare with str by default [#3351]
An earlier patch supporting Python 3 introduced the SaStringT class. With str type, default SaStringT cannot be compared. This commit is to allow compare with str class if without casting --- python/pyosaf/saAis.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/python/pyosaf/saAis.py b/python/pyosaf/saAis.py index 912523e69..2f2af641f 100644 --- a/python/pyosaf/saAis.py +++ b/python/pyosaf/saAis.py @@ -53,6 +53,30 @@ if PY3: return self.value.decode('utf-8') else: return self.__repr__() + + def __eq__(self, other): + if isinstance(other, str): + return self.value == other.encode('utf-8') + return super().__eq__(other) + + def __ne__(self, other): + return not self.__eq__(other) + + def __lt__(self, other): + if isinstance(other, str): + return self.value < other.encode('utf-8') + return super().__lt__(other) + + def __gt__(self, other): + if isinstance(other, str): + return self.value > other.encode('utf-8') + return super().__gt__(other) + + def __ge__(self, other): + return self.__gt__(other) or self.__eq__(other) + + def __le__(self, other): + return self.__lt__(other) or self.__eq__(other) else: SaStringT = ctypes.c_char_p -- 2.43.0 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel