clean etherlab: pep8, W601 .has_key() is deprecated, use 'in'
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Sat, 29 Sep 2018 13:34:06 +0300
changeset 2377 88a9d64560d3
parent 2376 47775c9367bd
child 2378 7aa47c09f8f5
clean etherlab: pep8, W601 .has_key() is deprecated, use 'in'
etherlab/EtherCATManagementEditor.py
etherlab/EthercatCFileGenerator.py
etherlab/etherlab.py
--- a/etherlab/EtherCATManagementEditor.py	Sat Sep 29 13:30:41 2018 +0300
+++ b/etherlab/EtherCATManagementEditor.py	Sat Sep 29 13:34:06 2018 +0300
@@ -1692,7 +1692,7 @@
                 row_data.append(hex_address)
 
                 # append description
-                if self.RegisterDescriptionDict.has_key(hex_address):
+                if hex_address in self.RegisterDescriptionDict:
                     row_data.append(self.RegisterDescriptionDict[hex_address])
                 else:
                     row_data.append("")
--- a/etherlab/EthercatCFileGenerator.py	Sat Sep 29 13:30:41 2018 +0300
+++ b/etherlab/EthercatCFileGenerator.py	Sat Sep 29 13:34:06 2018 +0300
@@ -75,7 +75,7 @@
         raise ValueError, _("Type of location \"%s\" not yet supported!") % entry_infos["var_name"]
 
     if not entry_infos.get("no_decl", False):
-        if entry_infos.has_key("real_var"):
+        if "real_var" in entry_infos:
             str_completion["located_variables_declaration"].append(
                 "IEC_%(var_type)s %(real_var)s;" % entry_infos)
         else:
@@ -87,7 +87,7 @@
             entry_infos["extra_decl"] = declaration
             str_completion["located_variables_declaration"].append(
                  "IEC_%(var_type)s *%(extra_decl)s = &%(real_var)s;" % entry_infos)
-    elif not entry_infos.has_key("real_var"):
+    elif "real_var" not in entry_infos:
         entry_infos["real_var"] = "beremiz" + entry_infos["var_name"]
 
     str_completion["used_pdo_entry_offset_variables_declaration"].append(
@@ -490,7 +490,7 @@
                             else:
                                 raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"]
 
-                            if not dynamic_pdos.has_key(pdo_type):
+                            if pdo_type not in dynamic_pdos:
                                 raise ValueError, _("No Sync manager defined for %s!") % pdo_type
 
                             ConfigureVariable(entry_infos, str_completion)
--- a/etherlab/etherlab.py	Sat Sep 29 13:30:41 2018 +0300
+++ b/etherlab/etherlab.py	Sat Sep 29 13:34:06 2018 +0300
@@ -240,7 +240,7 @@
 
                     for device in self.devices_xpath(self.modules_infos):
                         device_group = device.getGroupType()
-                        if not vendor_category["groups"].has_key(device_group):
+                        if device_group not in vendor_category["groups"]:
                             raise ValueError, "Not such group \"%\"" % device_group
                         vendor_category["groups"][device_group]["devices"].append(
                             (device.getType().getcontent(), device))