Hi Thien,
It's better if other operators can be applied, e.i, <, >, ....

B.R/Thang

-----Original Message-----
From: Thien Minh Huynh <thien.m.hu...@dektech.com.au> 
Sent: Tuesday, April 23, 2024 10:45 AM
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]

SaStringT class is introduced in previous commit support python3.
Default SaStringT cannot compare with other type.

This commit is to allow compare with str class if without casting
---
 python/pyosaf/saAis.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/python/pyosaf/saAis.py b/python/pyosaf/saAis.py index 
912523e69..d890c6a27 100644
--- a/python/pyosaf/saAis.py
+++ b/python/pyosaf/saAis.py
@@ -53,6 +53,16 @@ if PY3:
                                return self.value.decode('utf-8')
                        else:
                                return self.__repr__()
+
+               def __eq__(self, other):
+                       if isinstance(other, str):
+                               return str(self).__eq__(other)
+                       return super().__eq__(other)
+
+               def __ne__(self, other):
+                       if isinstance(other, str):
+                               return str(self).__ne__(other)
+                       return super().__ne__(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

Reply via email to