[Fix build on systems with Python 3 2/3] qmi-codegen python3: fix dict.has_key('key') to 'key' in dict

Shawn J. Goff shawn7400 at gmail.com
Mon Dec 17 13:27:11 PST 2012


From: "Shawn J. Goff" <shawn.goff at accelecon.com>

Python 3 no longer supports the has_key() method.

sed regex:
s/\([^ ]\+\)\.has_key(\([^)]*\))/\2 in \1/g
---
 build-aux/qmi-codegen/Variable.py | 2 +-
 utils/qmidb/Fields.py             | 2 +-
 utils/qmidb/Structs.py            | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/build-aux/qmi-codegen/Variable.py b/build-aux/qmi-codegen/Variable.py
index 8e4bfc6..c238471 100644
--- a/build-aux/qmi-codegen/Variable.py
+++ b/build-aux/qmi-codegen/Variable.py
@@ -45,7 +45,7 @@ class Variable:
         self.needs_dispose = False
 
         self.endian = "QMI_ENDIAN_LITTLE"
-        if dictionary.has_key('endian'):
+        if 'endian' in dictionary:
             endian = dictionary['endian']
             if endian == 'network' or endian == 'big':
                 self.endian = "QMI_ENDIAN_BIG"
diff --git a/utils/qmidb/Fields.py b/utils/qmidb/Fields.py
index 9df70a2..cd2e86b 100755
--- a/utils/qmidb/Fields.py
+++ b/utils/qmidb/Fields.py
@@ -151,7 +151,7 @@ class Fields:
             self.byid[field.id] = field
 
     def has_child(self, fid):
-        return self.byid.has_key(fid)
+        return fid in self.byid
 
     def get_child(self, fid):
         return self.byid[fid]
diff --git a/utils/qmidb/Structs.py b/utils/qmidb/Structs.py
index 34e001e..f068fc8 100755
--- a/utils/qmidb/Structs.py
+++ b/utils/qmidb/Structs.py
@@ -336,7 +336,7 @@ class Structs(utils.DbFile):
             s.validate(fields, self)
 
     def has_child(self, sid):
-        return self.structs.has_key(sid)
+        return sid in self.structs
 
     def get_child(self, sid):
         return self.structs[sid]
-- 
1.8.0.2



More information about the libqmi-devel mailing list