Replace dict.has_key with the 'in' operator

The deprecated has_key method will be removed from dicts in Python 3.

For custom dict-like classes, has_key() is kept on Python 2,
but disabled for Python 3.

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Petr Viktorin
2015-07-30 17:29:39 +02:00
committed by Tomas Babej
parent 8b88caa110
commit 6a741b51da
14 changed files with 56 additions and 55 deletions

View File

@@ -370,10 +370,10 @@ class StateFile:
self._load()
if not self.modules.has_key(module):
if module not in self.modules:
self.modules[module] = {}
if not self.modules.has_key(key):
if key not in self.modules:
self.modules[module][key] = value
self.save()
@@ -387,7 +387,7 @@ class StateFile:
"""
self._load()
if not self.modules.has_key(module):
if module not in self.modules:
return None
return self.modules[module].get(key, None)
@@ -429,7 +429,7 @@ class StateFile:
Can be used to determine if a service is configured.
"""
if self.modules.has_key(module):
if module in self.modules:
return True
else:
return False