Skip to content

Commit 9d55082

Browse files
authored
[configlet][portconfig] Remove calls to dict.has_key() which is not available in Python 3 (#1247)
Replace calls to `dict.has_key()` with `in`. It appears the `2to3` tool missed these.
1 parent d07ca5f commit 9d55082

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

scripts/configlet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def db_update(t, k, lst):
102102
if tuple_k in ct_keys:
103103
data = db.get_entry(t, k)
104104
for i in lst:
105-
if not data.has_key(i) or data[i] != lst[i]:
105+
if i not in data or data[i] != lst[i]:
106106
to_upd = True
107107
break
108108
else:
@@ -116,7 +116,7 @@ def db_delete_fields(t, k, lst):
116116
to_set = False
117117
data = db.get_entry(t, k)
118118
for i in lst:
119-
if data.has_key(i):
119+
if i in data:
120120
data.pop(i)
121121
to_set = True
122122

scripts/portconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ class portconfig(object):
4242

4343
# check whether table for this port exists
4444
port_tables = self.db.get_table(PORT_TABLE_NAME)
45-
if not port_tables.has_key(port):
45+
if port not in port_tables:
4646
raise Exception("Invalid port specified")
4747

4848
def list_params(self, port):
4949
# chack whether table for this port exists
5050
port_tables = self.db.get_table(PORT_TABLE_NAME)
51-
if port_tables.has_key(port):
51+
if port in port_tables:
5252
print(port_tables[port])
5353

5454
def set_speed(self, port, speed):

0 commit comments

Comments
 (0)