Skip to content

Commit

Permalink
[configlet][portconfig] Remove calls to dict.has_key() which is not a…
Browse files Browse the repository at this point in the history
…vailable in Python 3 (#1247)

Replace calls to `dict.has_key()` with `in`. It appears the `2to3` tool missed these.
  • Loading branch information
jleveque authored Nov 18, 2020
1 parent d07ca5f commit 9d55082
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts/configlet
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def db_update(t, k, lst):
if tuple_k in ct_keys:
data = db.get_entry(t, k)
for i in lst:
if not data.has_key(i) or data[i] != lst[i]:
if i not in data or data[i] != lst[i]:
to_upd = True
break
else:
Expand All @@ -116,7 +116,7 @@ def db_delete_fields(t, k, lst):
to_set = False
data = db.get_entry(t, k)
for i in lst:
if data.has_key(i):
if i in data:
data.pop(i)
to_set = True

Expand Down
4 changes: 2 additions & 2 deletions scripts/portconfig
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ class portconfig(object):

# check whether table for this port exists
port_tables = self.db.get_table(PORT_TABLE_NAME)
if not port_tables.has_key(port):
if port not in port_tables:
raise Exception("Invalid port specified")

def list_params(self, port):
# chack whether table for this port exists
port_tables = self.db.get_table(PORT_TABLE_NAME)
if port_tables.has_key(port):
if port in port_tables:
print(port_tables[port])

def set_speed(self, port, speed):
Expand Down

0 comments on commit 9d55082

Please sign in to comment.