1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 02:40:50 +01:00

utils/types: implement __ne__ for caseless_string

This should have been handled by the @total_ordering decorator, but
isn't due to

	https://bugs.python.org/issue25732

(briefly, total_ordering is back-ported from Python 3, where the base
object provides the default implementation of __ne__ based on __eq__, so
total_ordering did not override it; this, however does not happen in
Python 2).
This commit is contained in:
Sergei Trofimov 2018-06-14 14:41:20 +01:00 committed by setrofim
parent 51452d204c
commit f1c945bb5e

View File

@ -106,6 +106,11 @@ class caseless_string(str):
other = other.lower()
return self.lower() == other
def __ne__(self, other):
if isinstance(other, basestring):
other = other.lower()
return self.lower() != other
def __lt__(self, other):
if isinstance(other, basestring):
other = other.lower()