clean etherlab: pep8, E129 visually indented line with same indent as next logical line
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Sat, 29 Sep 2018 14:57:15 +0300
changeset 2379 015b724c30a5
parent 2378 7aa47c09f8f5
child 2380 b35bce45bc5a
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
etherlab/ConfigEditor.py
etherlab/EtherCATManagementEditor.py
etherlab/EthercatCFileGenerator.py
etherlab/etherlab.py
--- a/etherlab/ConfigEditor.py	Sat Sep 29 13:44:02 2018 +0300
+++ b/etherlab/ConfigEditor.py	Sat Sep 29 14:57:15 2018 +0300
@@ -424,8 +424,8 @@
                 if result is not None:
                     location = map(int, result.group(1).split('.'))
                 master_location = self.ParentWindow.GetMasterLocation()
-                if (master_location == tuple(location[:len(master_location)]) and
-                    len(location) - len(master_location) == 3):
+                if master_location == tuple(location[:len(master_location)]) and \
+                   len(location) - len(master_location) == 3:
                     values = tuple(location[len(master_location):])
                     var_type = self.ParentWindow.Controler.GetSlaveVariableDataType(*values)
                     if col == 2:
@@ -491,8 +491,8 @@
                 access = values[2]
             if location is not None:
                 master_location = self.ParentWindow.GetMasterLocation()
-                if (master_location == tuple(location[:len(master_location)]) and
-                    len(location) - len(master_location) == 3):
+                if master_location == tuple(location[:len(master_location)]) and \
+                   len(location) - len(master_location) == 3:
                     if access in ["wo", "rw"]:
                         self.ParentWindow.AddStartupCommand(*location[len(master_location):])
                     else:
@@ -904,8 +904,8 @@
             slaves = self.Controler.GetSlaves(**self.CurrentNodesFilter)
             data = []
             for variable in self.ProcessVariables:
-                if (variable["ReadFrom"] == "" or variable["ReadFrom"][0] in slaves or
-                    variable["WriteTo"] == "" or variable["WriteTo"][0] in slaves):
+                if variable["ReadFrom"] == "" or variable["ReadFrom"][0] in slaves or \
+                   variable["WriteTo"] == "" or variable["WriteTo"][0] in slaves:
                     data.append(variable)
             self.ProcessVariablesTable.SetData(data)
             self.ProcessVariablesTable.ResetView(self.ProcessVariablesGrid)
@@ -1014,8 +1014,8 @@
         col = self.ProcessVariablesGrid.GetGridCursorCol()
         row = self.ProcessVariablesGrid.GetGridCursorRow()
         colname = self.ProcessVariablesTable.GetColLabelValue(col, False)
-        if (keycode in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE) and
-            (colname.startswith("Read from") or colname.startswith("Write to"))):
+        if keycode in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE) and \
+           (colname.startswith("Read from") or colname.startswith("Write to")):
             self.ProcessVariablesTable.SetValue(row, col, "")
             self.SaveProcessVariables()
             wx.CallAfter(self.ProcessVariablesTable.ResetView, self.ProcessVariablesGrid)
--- a/etherlab/EtherCATManagementEditor.py	Sat Sep 29 13:44:02 2018 +0300
+++ b/etherlab/EtherCATManagementEditor.py	Sat Sep 29 14:57:15 2018 +0300
@@ -68,17 +68,19 @@
         self.EtherCATManagementClassObject = {}
 
         # fill EtherCAT Management Treebook
-        for pname, pclass, subs in [
+        panels = [
             ("Slave State",        SlaveStatePanelClass, []),
             ("SDO Management",     SDOPanelClass, []),
             ("PDO Monitoring",     PDOPanelClass, []),
             ("ESC Management",     EEPROMAccessPanel, [
-                    ("Smart View", SlaveSiiSmartView),
-                    ("Hex View", HexView)]),
-            ("Register Access",     RegisterAccessPanel, [])]:
-                self.AddPage(pclass(self, self.Controler), pname)
-                for spname, spclass in subs:
-                    self.AddSubPage(spclass(self, self.Controler), spname)
+                ("Smart View", SlaveSiiSmartView),
+                ("Hex View", HexView)]),
+            ("Register Access",     RegisterAccessPanel, [])
+        ]
+        for pname, pclass, subs in panels:
+            self.AddPage(pclass(self, self.Controler), pname)
+            for spname, spclass in subs:
+                self.AddSubPage(spclass(self, self.Controler), spname)
 
         self.Bind(wx.EVT_TREEBOOK_PAGE_CHANGED, self.OnPageChanged)
         self.Bind(wx.EVT_TREEBOOK_PAGE_CHANGING, self.OnPageChanging)
@@ -2126,29 +2128,29 @@
         # ----------------------- Main Sizer and Update Button --------------------------------------------
         self.MasterStateSizer = {"main": wx.BoxSizer(wx.VERTICAL)}
         for key, attr in [
-            ("innerMain",           [1, 10, 2, 10]),
-            ("innerTopHalf",        [2, 10, 1, 10]),
-            ("innerBottomHalf",     [2, 10, 1, 10]),
-            ("innerMasterState",    [2, 10, 3, 10]),
-            ("innerDeviceInfo",     [4, 10, 3, 10]),
-            ("innerFrameInfo",      [4, 10, 5, 10])]:
+                ("innerMain",           [1, 10, 2, 10]),
+                ("innerTopHalf",        [2, 10, 1, 10]),
+                ("innerBottomHalf",     [2, 10, 1, 10]),
+                ("innerMasterState",    [2, 10, 3, 10]),
+                ("innerDeviceInfo",     [4, 10, 3, 10]),
+                ("innerFrameInfo",      [4, 10, 5, 10])]:
             self.MasterStateSizer[key] = wx.FlexGridSizer(cols=attr[0], hgap=attr[1], rows=attr[2], vgap=attr[3])
 
         self.UpdateButton = wx.Button(self, label=_('Update'))
         self.UpdateButton.Bind(wx.EVT_BUTTON, self.OnButtonClick)
 
         for key, label in [
-            ('masterState', 'EtherCAT Master State'),
-            ('deviceInfo', 'Ethernet Network Card Information'),
-            ('frameInfo', 'Network Frame Information')]:
+                ('masterState', 'EtherCAT Master State'),
+                ('deviceInfo', 'Ethernet Network Card Information'),
+                ('frameInfo', 'Network Frame Information')]:
             self.StaticBox[key] = wx.StaticBox(self, label=_(label))
             self.MasterStateSizer[key] = wx.StaticBoxSizer(self.StaticBox[key])
 
         # ----------------------- Master State -----------------------------------------------------------
         for key, label in [
-            ('Phase', 'Phase:'),
-            ('Active', 'Active:'),
-            ('Slaves', 'Slave Count:')]:
+                ('Phase', 'Phase:'),
+                ('Active', 'Active:'),
+                ('Slaves', 'Slave Count:')]:
             self.StaticText[key] = wx.StaticText(self, label=_(label))
             self.TextCtrl[key] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
             self.MasterStateSizer['innerMasterState'].AddMany([self.StaticText[key], self.TextCtrl[key]])
@@ -2157,11 +2159,11 @@
 
         # ----------------------- Ethernet Network Card Information ---------------------------------------
         for key, label in [
-            ('Main', 'MAC Address:'),
-            ('Link', 'Link State:'),
-            ('Tx frames', 'Tx Frames:'),
-            ('Rx frames', 'Rx Frames:'),
-            ('Lost frames', 'Lost Frames:')]:
+                ('Main', 'MAC Address:'),
+                ('Link', 'Link State:'),
+                ('Tx frames', 'Tx Frames:'),
+                ('Rx frames', 'Rx Frames:'),
+                ('Lost frames', 'Lost Frames:')]:
             self.StaticText[key] = wx.StaticText(self, label=_(label))
             self.TextCtrl[key] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
             self.MasterStateSizer['innerDeviceInfo'].AddMany([self.StaticText[key], self.TextCtrl[key]])
@@ -2170,10 +2172,10 @@
 
         # ----------------------- Network Frame Information -----------------------------------------------
         for key, label in [
-            ('Tx frame rate [1/s]', 'Tx Frame Rate [1/s]:'),
-            ('Rx frame rate [1/s]', 'Tx Rate [kByte/s]:'),
-            ('Loss rate [1/s]', 'Loss Rate [1/s]:'),
-            ('Frame loss [%]', 'Frame Loss [%]:')]:
+                ('Tx frame rate [1/s]', 'Tx Frame Rate [1/s]:'),
+                ('Rx frame rate [1/s]', 'Tx Rate [kByte/s]:'),
+                ('Loss rate [1/s]', 'Loss Rate [1/s]:'),
+                ('Frame loss [%]', 'Frame Loss [%]:')]:
             self.StaticText[key] = wx.StaticText(self, label=_(label))
             self.MasterStateSizer['innerFrameInfo'].Add(self.StaticText[key])
             self.TextCtrl[key] = {}
--- a/etherlab/EthercatCFileGenerator.py	Sat Sep 29 13:44:02 2018 +0300
+++ b/etherlab/EthercatCFileGenerator.py	Sat Sep 29 14:57:15 2018 +0300
@@ -396,14 +396,14 @@
                             entry_type = entry.getDataType().getcontent()
                             if entry_infos["var_type"] != entry_type:
                                 message = _("Wrong type for location \"%s\"!") % entry_infos["var_name"]
-                                if (self.Controler.GetSizeOfType(entry_infos["var_type"]) !=
-                                    self.Controler.GetSizeOfType(entry_type)):
+                                if self.Controler.GetSizeOfType(entry_infos["var_type"]) != \
+                                   self.Controler.GetSizeOfType(entry_type):
                                     raise ValueError(message)
                                 else:
                                     self.Controler.GetCTRoot().logger.write_warning(_("Warning: ") + message + "\n")
 
-                            if (entry_infos["dir"] == "I" and pdo_type != "Inputs" or
-                                entry_infos["dir"] == "Q" and pdo_type != "Outputs"):
+                            if (entry_infos["dir"] == "I" and pdo_type != "Inputs") or \
+                               (entry_infos["dir"] == "Q" and pdo_type != "Outputs"):
                                 raise ValueError(_("Wrong direction for location \"%s\"!") % entry_infos["var_name"])
 
                             ConfigureVariable(entry_infos, str_completion)
@@ -483,8 +483,8 @@
 
                             if entry_infos["var_type"] != entry["Type"]:
                                 message = _("Wrong type for location \"%s\"!") % entry_infos["var_name"]
-                                if (self.Controler.GetSizeOfType(entry_infos["var_type"]) !=
-                                    self.Controler.GetSizeOfType(entry["Type"])):
+                                if self.Controler.GetSizeOfType(entry_infos["var_type"]) != \
+                                   self.Controler.GetSizeOfType(entry["Type"]):
                                     raise ValueError(message)
                                 else:
                                     self.Controler.GetCTRoot().logger.write_warning(message + "\n")
--- a/etherlab/etherlab.py	Sat Sep 29 13:44:02 2018 +0300
+++ b/etherlab/etherlab.py	Sat Sep 29 14:57:15 2018 +0300
@@ -311,8 +311,8 @@
                 for device_type, device_infos in group_infos["devices"]:
                     product_code = ExtractHexDecValue(device_infos.getType().getProductCode())
                     revision_number = ExtractHexDecValue(device_infos.getType().getRevisionNo())
-                    if (product_code == ExtractHexDecValue(module_infos["product_code"]) and
-                        revision_number == ExtractHexDecValue(module_infos["revision_number"])):
+                    if product_code == ExtractHexDecValue(module_infos["product_code"]) and \
+                       revision_number == ExtractHexDecValue(module_infos["revision_number"]):
                         self.cntdevice = device_infos
                         self.cntdeviceType = device_type
                         return device_infos, self.GetModuleExtraParams(vendor, product_code, revision_number)
@@ -342,7 +342,7 @@
                 else:
                     params_values = {}
                     for (param, param_infos), value in zip(
-                        self.MODULES_EXTRA_PARAMS, row[3:]):
+                            self.MODULES_EXTRA_PARAMS, row[3:]):
                         if value != "":
                             params_values[param] = int(value)
                     self.ModulesExtraParams[