clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Sat, 29 Sep 2018 19:10:43 +0300
changeset 2407 5f2b1bb464a0
parent 2406 ffd091b51cd0
child 2408 23978e5b039a
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
etherlab/CommonEtherCATFunction.py
etherlab/EtherCATManagementEditor.py
etherlab/EthercatCFileGenerator.py
etherlab/EthercatCIA402Slave.py
etherlab/EthercatMaster.py
etherlab/runtime_etherlab.py
--- a/etherlab/CommonEtherCATFunction.py	Sat Sep 29 18:59:41 2018 +0300
+++ b/etherlab/CommonEtherCATFunction.py	Sat Sep 29 19:10:43 2018 +0300
@@ -322,12 +322,12 @@
                 # if entry name exists, save entry data
                 if ExtractName(entry.getName()) is not None:
                     entry_infos = {
-                                "entry_index": index,
-                                "subindex": subindex,
-                                "name": ExtractName(entry.getName()),
-                                "bitlen": entry.getBitLen(),
-                                "type": entry.getDataType().getcontent()
-                                    }
+                        "entry_index": index,
+                        "subindex": subindex,
+                        "name": ExtractName(entry.getName()),
+                        "bitlen": entry.getBitLen(),
+                        "type": entry.getDataType().getcontent()
+                    }
                     self.TxPDOInfo.append(entry_infos)
                     count += 1
 
@@ -352,12 +352,12 @@
                 # if entry name exists, save entry data
                 if ExtractName(entry.getName()) is not None:
                     entry_infos = {
-                                "entry_index": index,
-                                "subindex": subindex,
-                                "name": ExtractName(entry.getName()),
-                                "bitlen": str(entry.getBitLen()),
-                                "type": entry.getDataType().getcontent()
-                                    }
+                        "entry_index": index,
+                        "subindex": subindex,
+                        "name": ExtractName(entry.getName()),
+                        "bitlen": str(entry.getBitLen()),
+                        "type": entry.getDataType().getcontent()
+                    }
                     self.RxPDOInfo.append(entry_infos)
                     count += 1
 
@@ -1187,7 +1187,7 @@
             coe = mb.getCoE()
             if coe is not None:
                 for bit, flag in enumerate(["SdoInfo", "PdoAssign", "PdoConfig",
-                                           "PdoUpload", "CompleteAccess"]):
+                                            "PdoUpload", "CompleteAccess"]):
                     if getattr(coe, "get%s" % flag)() is not None:
                         coe_details += 1 << bit
         eeprom.append("{:0>2x}".format(coe_details))
--- a/etherlab/EtherCATManagementEditor.py	Sat Sep 29 18:59:41 2018 +0300
+++ b/etherlab/EtherCATManagementEditor.py	Sat Sep 29 19:10:43 2018 +0300
@@ -2127,12 +2127,10 @@
 
         # --------------------------------- Main Sizer ----------------------------------------------------
         for key, sub, in [
-            ('innerTopHalf', [
-                    'masterState', 'deviceInfo']),
-            ('innerBottomHalf', [
-                    'frameInfo']),
-            ('innerMain', [
-                    'innerTopHalf', 'innerBottomHalf'])]:
+                ('innerTopHalf', ['masterState', 'deviceInfo']),
+                ('innerBottomHalf', ['frameInfo']),
+                ('innerMain', ['innerTopHalf', 'innerBottomHalf'])
+        ]:
             for key2 in sub:
                 self.MasterStateSizer[key].AddSizer(self.MasterStateSizer[key2])
 
--- a/etherlab/EthercatCFileGenerator.py	Sat Sep 29 18:59:41 2018 +0300
+++ b/etherlab/EthercatCFileGenerator.py	Sat Sep 29 19:10:43 2018 +0300
@@ -88,7 +88,7 @@
         for declaration in entry_infos.get("extra_declarations", []):
             entry_infos["extra_decl"] = declaration
             str_completion["located_variables_declaration"].append(
-                 "IEC_%(var_type)s *%(extra_decl)s = &%(real_var)s;" % entry_infos)
+                "IEC_%(var_type)s *%(extra_decl)s = &%(real_var)s;" % entry_infos)
     elif "real_var" not in entry_infos:
         entry_infos["real_var"] = "beremiz" + entry_infos["var_name"]
 
@@ -100,18 +100,18 @@
             "unsigned int slave%(slave)d_%(index).4x_%(subindex).2x_bit;" % entry_infos)
 
         str_completion["used_pdo_entry_configuration"].append(
-             ("    {%(alias)d, %(position)d, 0x%(vendor).8x, 0x%(product_code).8x, " +
-              "0x%(index).4x, %(subindex)d, &slave%(slave)d_%(index).4x_%(subindex).2x, " +
-              "&slave%(slave)d_%(index).4x_%(subindex).2x_bit},") % entry_infos)
+            ("    {%(alias)d, %(position)d, 0x%(vendor).8x, 0x%(product_code).8x, " +
+             "0x%(index).4x, %(subindex)d, &slave%(slave)d_%(index).4x_%(subindex).2x, " +
+             "&slave%(slave)d_%(index).4x_%(subindex).2x_bit},") % entry_infos)
 
         if entry_infos["dir"] == "I":
             str_completion["retrieve_variables"].append(
-              ("    %(real_var)s = EC_READ_BIT(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " +
-               "slave%(slave)d_%(index).4x_%(subindex).2x_bit);") % entry_infos)
+                ("    %(real_var)s = EC_READ_BIT(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " +
+                 "slave%(slave)d_%(index).4x_%(subindex).2x_bit);") % entry_infos)
         elif entry_infos["dir"] == "Q":
             str_completion["publish_variables"].append(
-              ("    EC_WRITE_BIT(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " +
-               "slave%(slave)d_%(index).4x_%(subindex).2x_bit, %(real_var)s);") % entry_infos)
+                ("    EC_WRITE_BIT(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " +
+                 "slave%(slave)d_%(index).4x_%(subindex).2x_bit, %(real_var)s);") % entry_infos)
 
     else:
         str_completion["used_pdo_entry_configuration"].append(
@@ -532,7 +532,7 @@
                             pdo["entries"].append("    {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos)
                             if entry_infos["bitlen"] < module_extra_params["pdo_alignment"]:
                                 pdo["entries"].append("    {0x0000, 0x00, %d}, /* None */" % (
-                                        module_extra_params["pdo_alignment"] - entry_infos["bitlen"]))
+                                    module_extra_params["pdo_alignment"] - entry_infos["bitlen"]))
                             pdo["entries_number"] += 1
 
                             if pdo["entries_number"] == module_extra_params["max_pdo_size"]:
--- a/etherlab/EthercatCIA402Slave.py	Sat Sep 29 18:59:41 2018 +0300
+++ b/etherlab/EthercatCIA402Slave.py	Sat Sep 29 19:10:43 2018 +0300
@@ -164,12 +164,13 @@
                 "children": []
             }
             for name_frmt, iec_type, var_name_frmt, location_frmt in [
-                    ("%s Network Position", "UINT", "%s_pos", "%%IW%s"),
-                    ("%s Axis Ref", "AXIS_REF", "%s", "%%IW%s.402")
+                ("%s Network Position", "UINT", "%s_pos", "%%IW%s"),
+                ("%s Axis Ref", "AXIS_REF", "%s", "%%IW%s.402")
             ]
         ]
-        children.extend(self.CTNParent.GetDeviceLocationTree(
-                            self.GetSlavePos(), current_location, axis_name))
+        children.extend(self.CTNParent.GetDeviceLocationTree(self.GetSlavePos(),
+                                                             current_location,
+                                                             axis_name))
         return {
             "name": axis_name,
             "type": LOCATION_CONFNODE,
@@ -229,14 +230,15 @@
             ucase_blocktype = blocktype.upper()
             blockname = "_".join([ucase_blocktype, location_str])
 
-            extract_inputs = "\n".join(["""\
-    __SET_VAR(%s->, %s,, %s);""" % (blockname, input_name, input_value)
-                for (input_name, input_value) in [
-                    ("EXECUTE", "__GET_VAR(data__->EXECUTE)")] + [
+            extract_inputs = "\n".join([
+                """\
+                __SET_VAR(%s->, %s,, %s);""" % (blockname, input_name, input_value)
+                for (input_name, input_value) in
+                [("EXECUTE", "__GET_VAR(data__->EXECUTE)")] + [
                     (input["name"].upper(),
                      "__GET_VAR(data__->%s)" % input["name"].upper())
-                    for input in blocktype_infos["inputs"]]
-                ])
+                    for input in blocktype_infos["inputs"]
+                ]])
 
             return_outputs = "\n".join([
                 """\
@@ -246,8 +248,8 @@
                     "blockname": blockname
                 }
                 for output_name in ["DONE", "BUSY", "ERROR"] + [
-                        output["name"].upper()
-                        for output in blocktype_infos["outputs"]]
+                    output["name"].upper()
+                    for output in blocktype_infos["outputs"]]
             ])
 
             loc_dict = {
@@ -338,24 +340,24 @@
             loc_dict["var_name"] = var_name
 
             extern_located_variables_declaration.append(
-                    "IEC_%(var_type)s *%(var_name)s;" % loc_dict)
+                "IEC_%(var_type)s *%(var_name)s;" % loc_dict)
             entry_variables.append(
-                    "    IEC_%(var_type)s *%(name)s;" % loc_dict)
+                "    IEC_%(var_type)s *%(name)s;" % loc_dict)
             init_entry_variables.append(
-                    "    AxsPub.%(name)s = %(var_name)s;" % loc_dict)
+                "    AxsPub.%(name)s = %(var_name)s;" % loc_dict)
 
             self.CTNParent.FileGenerator.DeclareVariable(
-                    slave_pos, index, subindex, var_type, dir, var_name)
+                slave_pos, index, subindex, var_type, dir, var_name)
 
         # Add newline between string in list of generated strings for sections
         [fieldbus_interface_declaration, fieldbus_interface_definition,
          init_axis_params, extra_variables_retrieve, extra_variables_publish,
          extern_located_variables_declaration, entry_variables,
          init_entry_variables] = map("\n".join, [
-            fieldbus_interface_declaration, fieldbus_interface_definition,
-            init_axis_params, extra_variables_retrieve, extra_variables_publish,
-            extern_located_variables_declaration, entry_variables,
-            init_entry_variables])
+             fieldbus_interface_declaration, fieldbus_interface_definition,
+             init_axis_params, extra_variables_retrieve, extra_variables_publish,
+             extern_located_variables_declaration, entry_variables,
+             init_entry_variables])
 
         # Write generated content to CIA402 node file
         Gen_CIA402Nodefile_path = os.path.join(buildpath,
--- a/etherlab/EthercatMaster.py	Sat Sep 29 18:59:41 2018 +0300
+++ b/etherlab/EthercatMaster.py	Sat Sep 29 19:10:43 2018 +0300
@@ -734,9 +734,9 @@
                 subindex = read_from.getSubIndex()
                 location = current_location + (idx, )
                 var_type = self.GetSlaveVariableDataType(pos, index, subindex)
-                name = self.FileGenerator.DeclareVariable(
-                            pos, index, subindex, var_type, "I",
-                            self.GetProcessVariableName(location, var_type))
+                name = self.FileGenerator.DeclareVariable(pos, index, subindex,
+                                                          var_type, "I",
+                                                          self.GetProcessVariableName(location, var_type))
             if write_to is not None:
                 pos = write_to.getPosition()
                 index = write_to.getIndex()
@@ -745,8 +745,7 @@
                     location = current_location + (idx, )
                     var_type = self.GetSlaveVariableDataType(pos, index, subindex)
                     name = self.GetProcessVariableName(location, var_type)
-                self.FileGenerator.DeclareVariable(
-                            pos, index, subindex, var_type, "Q", name, True)
+                self.FileGenerator.DeclareVariable(pos, index, subindex, var_type, "Q", name, True)
 
         self.FileGenerator.GenerateCFile(Gen_Ethercatfile_path, location_str, self.BaseParams.getIEC_Channel())
 
--- a/etherlab/runtime_etherlab.py	Sat Sep 29 18:59:41 2018 +0300
+++ b/etherlab/runtime_etherlab.py	Sat Sep 29 19:10:43 2018 +0300
@@ -95,8 +95,8 @@
         if log:
             last = log.rpartition('\n')[2]
             for lvl, msg in re.findall(
-                            r'<(\d)>\[\s*\d*\.\d*\]\s*(EtherCAT\s*.*)$',
-                            log, re.MULTILINE):
+                    r'<(\d)>\[\s*\d*\.\d*\]\s*(EtherCAT\s*.*)$',
+                    log, re.MULTILINE):
                 PLCObject.LogMessage(
                     LogLevelsDict[{
                         "4": "WARNING",