From 61762c7aac99ca5f010e3d0de812180fd0d152e1 Mon Sep 17 00:00:00 2001 From: Ting Xu Date: Mon, 3 Jul 2023 08:08:33 +0000 Subject: packetforge: fix has_key invalid in python3 Python Dict attribute "has_key" was removed in Python3. Use "in" operation instead. Type: fix Signed-off-by: Ting Xu Change-Id: I7b63b0689e9970ca798921368c5616875f7d5682 --- extras/packetforge/ParseGraph.py | 2 +- extras/packetforge/ProtocolHeader.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'extras') diff --git a/extras/packetforge/ParseGraph.py b/extras/packetforge/ParseGraph.py index 188b0732ff6..31fc3039fed 100644 --- a/extras/packetforge/ParseGraph.py +++ b/extras/packetforge/ParseGraph.py @@ -91,7 +91,7 @@ class ParseGraph: return None def GetNode(self, name): - if self.nodeDict.has_key(name): + if name in self.nodeDict: return self.nodeDict[name] return None diff --git a/extras/packetforge/ProtocolHeader.py b/extras/packetforge/ProtocolHeader.py index 272b6557460..398a52d3455 100644 --- a/extras/packetforge/ProtocolHeader.py +++ b/extras/packetforge/ProtocolHeader.py @@ -136,7 +136,7 @@ class ProtocolHeader: key = exp[0:offset].strip() shift = int(exp[offset + 2 :].strip()) - if self.fieldDict.has_key(key): + if key in self.fieldDict: field = self.fieldDict[key] _, u16 = ExpressionConverter.ToNum(field.Value) if u16: @@ -144,7 +144,7 @@ class ProtocolHeader: else: return 0 - if self.attributeDict.has_key(key): + if key in self.attributeDict: attr = self.attributeDict[key] _, u16 = ExpressionConverter.ToNum(attr.Value) if u16: @@ -201,14 +201,14 @@ class ProtocolHeader: phf.UpdateValue(ExpressionConverter.IncreaseValue(phf.Value, size), True) def getField(self, name): - if not self.fieldDict.has_key(name): + if name not in self.fieldDict: return None field = self.fieldDict[name] return field.Value def getAttribute(self, name): - if not self.attributeDict.has_key(name): + if name not in self.attributeDict: return None return self.attributeDict[name].Value -- cgit 1.2.3-korg