Fix Hitlist comparison by adding __eq__() & __ne__() to Hit class

Signed-off-by: Labidurie Jerome <jerome.labidurie@orange.com>
This commit is contained in:
Labidurie Jerome 2019-05-17 10:00:41 +02:00
parent 1e2e6f590f
commit 280dc4a295
1 changed files with 10 additions and 0 deletions

View File

@ -394,6 +394,16 @@ class Hit(object):
def __getitem__(self, X): # Define this so this works: "%(line)" % hit
return getattr(self, X)
def __eq__(self, other):
return (self.filename == other.filename
and self.line == other.line
and self.column == other.column
and self.level == other.level
and self.name == other.name)
def __ne__(self, other):
return not self == other
# return CWEs
def cwes(self):
result = find_cwe_pattern.search(self.warning)