Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
papi: enhance MACAddress() equality
[vpp.git]
/
src
/
vpp-api
/
python
/
vpp_papi
/
macaddress.py
diff --git
a/src/vpp-api/python/vpp_papi/macaddress.py
b/src/vpp-api/python/vpp_papi/macaddress.py
index
02c90db
..
c3b10a3
100644
(file)
--- a/
src/vpp-api/python/vpp_papi/macaddress.py
+++ b/
src/vpp-api/python/vpp_papi/macaddress.py
@@
-54,8
+54,14
@@
class MACAddress():
return '%s(%s)' % (self.__class__.__name__, self.mac_string)
def __eq__(self, other):
return '%s(%s)' % (self.__class__.__name__, self.mac_string)
def __eq__(self, other):
+
if not isinstance(other, MACAddress):
if not isinstance(other, MACAddress):
- return NotImplemented
+ try:
+ # if it looks like a mac address, we'll take it.
+ # (allows for equality with scapy hw-addresses)
+ return self.mac_binary == MACAddress(other).mac_binary
+ except Exception:
+ return NotImplemented
return self.mac_binary == other.mac_binary
def __ne__(self, other):
return self.mac_binary == other.mac_binary
def __ne__(self, other):