cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 28 Sep 2018 19:20:32 +0300
changeset 2367 0fb54172a18b
parent 2366 d635680e4c2c
child 2368 642ae95218b6
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
etherlab/CommonEtherCATFunction.py
etherlab/ConfigEditor.py
etherlab/EtherCATManagementEditor.py
etherlab/EthercatMaster.py
--- a/etherlab/CommonEtherCATFunction.py	Fri Sep 28 19:16:12 2018 +0300
+++ b/etherlab/CommonEtherCATFunction.py	Fri Sep 28 19:20:32 2018 +0300
@@ -787,7 +787,7 @@
             if mb is not None :
                 for bit, mbprot in enumerate(mailbox_protocols):
                     if getattr(mb, "get%s" % mbprot)() is not None:
-                        data += 1<<bit
+                        data += 1 << bit
             data = "{:0>4x}".format(data)
             eeprom.append(data[2:4])
             eeprom.append(data[0:2])
@@ -1184,7 +1184,7 @@
                 for bit, flag in enumerate(["SdoInfo", "PdoAssign", "PdoConfig",
                                            "PdoUpload", "CompleteAccess"]):
                     if getattr(coe, "get%s" % flag)() is not None:
-                        coe_details += 1<<bit
+                        coe_details += 1 << bit
         eeprom.append("{:0>2x}".format(coe_details))
 
         # word 4 : FoE Details and EoE Details
--- a/etherlab/ConfigEditor.py	Fri Sep 28 19:16:12 2018 +0300
+++ b/etherlab/ConfigEditor.py	Fri Sep 28 19:20:32 2018 +0300
@@ -274,11 +274,11 @@
 
         variables_label = wx.StaticText(self.EthercatNodeEditor,
               label=_('Variable entries:'))
-        main_sizer.AddWindow(variables_label, border=10, flag=wx.TOP|wx.LEFT|wx.RIGHT)
+        main_sizer.AddWindow(variables_label, border=10, flag=wx.TOP | wx.LEFT | wx.RIGHT)
 
         self.NodeVariables = NodeVariablesSizer(self.EthercatNodeEditor, self.Controler)
         main_sizer.AddSizer(self.NodeVariables, border=10,
-            flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+            flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT)
 
         self.EthercatNodeEditor.SetSizer(main_sizer)
 
@@ -301,7 +301,7 @@
     # -------------------For EtherCAT Management ----------------------------------------------
     def _create_EtherCATManagementEditor(self, prnt):
         self.EtherCATManagementEditor = wx.ScrolledWindow(prnt,
-            style=wx.TAB_TRAVERSAL|wx.HSCROLL|wx.VSCROLL)
+            style=wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL)
         self.EtherCATManagementEditor.Bind(wx.EVT_SIZE, self.OnResize)
 
         self.EtherCATManagermentEditor_Main_Sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
@@ -448,7 +448,7 @@
             wx.CallAfter(self.ShowMessage, message)
 
     def ShowMessage(self, message):
-        message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR)
+        message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR)
         message.ShowModal()
         message.Destroy()
 
@@ -500,7 +500,7 @@
             wx.CallAfter(self.ShowMessage, message)
 
     def ShowMessage(self, message):
-        message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR)
+        message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR)
         message.ShowModal()
         message.Destroy()
 
@@ -606,7 +606,7 @@
         ]
 
     def _create_MasterStateEditor(self, prnt):
-        self.MasterStateEditor = wx.ScrolledWindow(prnt, style=wx.TAB_TRAVERSAL|wx.HSCROLL|wx.VSCROLL)
+        self.MasterStateEditor = wx.ScrolledWindow(prnt, style=wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL)
         self.MasterStateEditor.Bind(wx.EVT_SIZE, self.OnResize)
 
         self.MasterStateEditor_Panel_Main_Sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
@@ -634,7 +634,7 @@
 
     def _create_EthercatMasterEditor(self, prnt):
         self.EthercatMasterEditor = wx.ScrolledWindow(prnt,
-            style=wx.TAB_TRAVERSAL|wx.HSCROLL|wx.VSCROLL)
+            style=wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL)
         self.EthercatMasterEditor.Bind(wx.EVT_SIZE, self.OnResize)
 
         self.EthercatMasterEditorSizer = wx.BoxSizer(wx.VERTICAL)
@@ -700,7 +700,7 @@
 
         main_staticbox = wx.StaticBox(self.EthercatMasterEditor, label=_("Node filter:"))
         staticbox_sizer = wx.StaticBoxSizer(main_staticbox, wx.VERTICAL)
-        self.EthercatMasterEditorSizer.AddSizer(staticbox_sizer, 0, border=10, flag=wx.GROW|wx.ALL)
+        self.EthercatMasterEditorSizer.AddSizer(staticbox_sizer, 0, border=10, flag=wx.GROW | wx.ALL)
 
         main_staticbox_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=0)
         main_staticbox_sizer.AddGrowableCol(0)
@@ -708,22 +708,22 @@
         main_staticbox_sizer.AddGrowableRow(4)
         main_staticbox_sizer.AddGrowableRow(5)
         staticbox_sizer.AddSizer(main_staticbox_sizer, 1, flag=wx.GROW)
-        main_staticbox_sizer.AddWindow(self.NodesFilter, border=5, flag=wx.GROW|wx.ALL)
+        main_staticbox_sizer.AddWindow(self.NodesFilter, border=5, flag=wx.GROW | wx.ALL)
         main_staticbox_sizer.AddSizer(process_variables_header, border=5,
-              flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+              flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM)
         main_staticbox_sizer.AddWindow(self.ProcessVariablesGrid, 1,
-              border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+              border=5, flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM)
         main_staticbox_sizer.AddSizer(startup_commands_header,
-              border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+              border=5, flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM)
         main_staticbox_sizer.AddWindow(self.StartupCommandsGrid, 1,
-              border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+              border=5, flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM)
 
         second_staticbox = wx.StaticBox(self.EthercatMasterEditor, label=_("Nodes variables filter:"))
         second_staticbox_sizer = wx.StaticBoxSizer(second_staticbox, wx.VERTICAL)
-        second_staticbox_sizer.AddSizer(self.NodesVariables, 1, border=5, flag=wx.GROW|wx.ALL)
+        second_staticbox_sizer.AddSizer(self.NodesVariables, 1, border=5, flag=wx.GROW | wx.ALL)
 
         main_staticbox_sizer.AddSizer(second_staticbox_sizer, 1,
-            border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
+            border=5, flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM)
 
         self.EthercatMasterEditor.SetSizer(self.EthercatMasterEditorSizer)
 
@@ -981,7 +981,7 @@
             wx.CallAfter(self.ProcessVariablesTable.ResetView, self.ProcessVariablesGrid)
             event.Skip()
         else:
-            dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+            dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
             dialog.ShowModal()
             dialog.Destroy()
             event.Veto()
@@ -1047,7 +1047,7 @@
                 self.RefreshBuffer()
                 event.Skip()
             else:
-                dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+                dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
                 dialog.ShowModal()
                 dialog.Destroy()
                 event.Veto()
@@ -1109,13 +1109,13 @@
         ESI_files_label = wx.StaticText(parent,
             label=_("ESI Files:"))
         self.AddWindow(ESI_files_label, border=10,
-            flag=wx.TOP|wx.LEFT|wx.RIGHT)
+            flag=wx.TOP | wx.LEFT | wx.RIGHT)
 
         folder_tree_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=0)
         folder_tree_sizer.AddGrowableCol(0)
         folder_tree_sizer.AddGrowableRow(0)
         self.AddSizer(folder_tree_sizer, border=10,
-            flag=wx.GROW|wx.LEFT|wx.RIGHT)
+            flag=wx.GROW | wx.LEFT | wx.RIGHT)
 
         self.ESIFiles = FolderTree(parent, self.GetPath(), editable=False)
         self.ESIFiles.SetFilter(".xml")
@@ -1144,7 +1144,7 @@
         modules_label = wx.StaticText(parent,
             label=_("Modules library:"))
         self.AddSizer(modules_label, border=10,
-            flag=wx.LEFT|wx.RIGHT)
+            flag=wx.LEFT | wx.RIGHT)
 
         self.ModulesGrid = wx.gizmos.TreeListCtrl(parent,
               style=wx.TR_DEFAULT_STYLE |
@@ -1161,7 +1161,7 @@
         self.ModulesGrid.GetHeaderWindow().Bind(wx.EVT_MOTION,
             self.OnModulesGridHeaderMotion)
         self.AddWindow(self.ModulesGrid, border=10,
-            flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+            flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT)
 
         for colname, colsize, colalign in zip(
                 [_("Name")] + [param_infos["column_label"]
@@ -1242,7 +1242,7 @@
             else:
                 message = wx.MessageDialog(self,
                     _("No such XML file: %s\n") % filepath,
-                    _("Error"), wx.OK|wx.ICON_ERROR)
+                    _("Error"), wx.OK | wx.ICON_ERROR)
                 message.ShowModal()
                 message.Destroy()
         dialog.Destroy()
@@ -1256,7 +1256,7 @@
 
             dialog = wx.MessageDialog(self.ParentWindow,
                   _("Do you really want to delete the file '%s'?") % filename,
-                  _("Delete File"), wx.YES_NO|wx.ICON_QUESTION)
+                  _("Delete File"), wx.YES_NO | wx.ICON_QUESTION)
             remove = dialog.ShowModal() == wx.ID_YES
             dialog.Destroy()
 
@@ -1308,7 +1308,7 @@
                 except ValueError:
                     message = wx.MessageDialog(self,
                         _("Module %s must be an integer!") % stripped_column_label,
-                        _("Error"), wx.OK|wx.ICON_ERROR)
+                        _("Error"), wx.OK | wx.ICON_ERROR)
                     message.ShowModal()
                     message.Destroy()
                     event.Veto()
@@ -1335,7 +1335,7 @@
     def __init__(self, parent, database):
         wx.Dialog.__init__(self, parent,
               size=wx.Size(700, 500), title=_('ESI Files Database management'),
-              style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
+              style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
 
         main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
         main_sizer.AddGrowableCol(0)
@@ -1346,13 +1346,13 @@
              ("DeleteButton", "remove_element", _("Remove file from database"), None)])
         self.DatabaseSizer.SetControlMinSize(wx.Size(0, 0))
         main_sizer.AddSizer(self.DatabaseSizer, border=10,
-            flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
-
-        button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+            flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT)
+
+        button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
         button_sizer.GetAffirmativeButton().SetLabel(_("Add file to project"))
         button_sizer.GetCancelButton().SetLabel(_("Close"))
         main_sizer.AddSizer(button_sizer, border=10,
-              flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+              flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
 
         self.SetSizer(main_sizer)
 
@@ -1369,7 +1369,7 @@
 
     def _create_ModuleLibraryEditor(self, prnt):
         self.ModuleLibraryEditor = wx.ScrolledWindow(prnt,
-            style=wx.TAB_TRAVERSAL|wx.HSCROLL|wx.VSCROLL)
+            style=wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL)
         self.ModuleLibraryEditor.Bind(wx.EVT_SIZE, self.OnResize)
 
         self.ModuleLibrarySizer = LibraryEditorSizer(self.ModuleLibraryEditor,
--- a/etherlab/EtherCATManagementEditor.py	Fri Sep 28 19:16:12 2018 +0300
+++ b/etherlab/EtherCATManagementEditor.py	Fri Sep 28 19:20:32 2018 +0300
@@ -535,7 +535,7 @@
         @param data: SDO data after parsing "SDOParser" method
         """
         wx.grid.Grid.__init__(self, parent, -1, size=(830, 490),
-                              style=wx.EXPAND|wx.ALIGN_CENTRE_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
+                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
 
         self.Controler = parent.Controler
         self.parent = parent
@@ -809,7 +809,7 @@
         @param count : page number
         """
         wx.grid.Grid.__init__(self, parent, -1, size=(500, 400), pos=wx.Point(0, 0),
-                              style=wx.EXPAND|wx.ALIGN_CENTRE_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
+                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
 
         self.Controler = parent.Controler
 
@@ -988,7 +988,7 @@
             self.SetEEPROMData()
             dialog = wx.FileDialog(self, _("Save as..."), os.getcwd(),
                                    "slave0.bin",  _("bin files (*.bin)|*.bin|All files|*.*"),
-                                   wx.SAVE|wx.OVERWRITE_PROMPT)
+                                   wx.SAVE | wx.OVERWRITE_PROMPT)
 
             if dialog.ShowModal() == wx.ID_OK:
                 filepath = dialog.GetPath()
@@ -1334,7 +1334,7 @@
         @param event : wx.EVT_BUTTON object
         """
         dialog = wx.FileDialog(self, _("Save as..."), os.getcwd(), "slave0.bin",
-                               _("bin files (*.bin)|*.bin|All files|*.*"), wx.SAVE|wx.OVERWRITE_PROMPT)
+                               _("bin files (*.bin)|*.bin|All files|*.*"), wx.SAVE | wx.OVERWRITE_PROMPT)
 
         if dialog.ShowModal() == wx.ID_OK:
             filepath = dialog.GetPath()
@@ -1398,7 +1398,7 @@
         self.Col = col
 
         wx.grid.Grid.__init__(self, parent, -1, size=(830, 450),
-                              style=wx.ALIGN_CENTRE_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
+                              style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
 
     def SetValue(self, value):
         """
@@ -1924,7 +1924,7 @@
         self.RegisterAccessPanel = self.parent.parent.parent
 
         wx.grid.Grid.__init__(self, parent, -1, size=(820, 300),
-                              style=wx.EXPAND|wx.ALIGN_CENTRE_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
+                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
 
         for evt, mapping_method in [(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
                                     (gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
@@ -2016,7 +2016,7 @@
         # user can enter a value in case that user double-clicked 'Dec' or 'Hex' value.
         if event.GetCol() == 1 or event.GetCol() == 2:
             dlg = wx.TextEntryDialog(self, "Enter hex(0xnnnn) or dec(n) value",
-                                     "Register Modify Dialog", style=wx.OK|wx.CANCEL)
+                                     "Register Modify Dialog", style=wx.OK | wx.CANCEL)
 
             # Setting value in initial dialog value
             start_value = self.GetCellValue(event.GetRow(), event.GetCol())
@@ -2072,7 +2072,7 @@
         self.Col = col
 
         wx.grid.Grid.__init__(self, parent, -1, size=(820, 150),
-                              style=wx.EXPAND|wx.ALIGN_CENTRE_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
+                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
 
     def SetValue(self, parent, data):
         """
--- a/etherlab/EthercatMaster.py	Fri Sep 28 19:16:12 2018 +0300
+++ b/etherlab/EthercatMaster.py	Fri Sep 28 19:20:32 2018 +0300
@@ -444,14 +444,14 @@
             dialog = wx.MessageDialog(app_frame,
                 _("The current network configuration will be deleted.\nDo you want to continue?"),
                 _("Scan Network"),
-                wx.YES_NO|wx.ICON_QUESTION)
+                wx.YES_NO | wx.ICON_QUESTION)
             execute = dialog.ShowModal() == wx.ID_YES
             dialog.Destroy()
 
         if execute:
             error, returnVal = self.RemoteExec(SCAN_COMMAND, returnVal=None)
             if error != 0:
-                dialog = wx.MessageDialog(app_frame, returnVal, "Error", wx.OK|wx.ICON_ERROR)
+                dialog = wx.MessageDialog(app_frame, returnVal, "Error", wx.OK | wx.ICON_ERROR)
                 dialog.ShowModal()
                 dialog.Destroy()
             elif returnVal is not None: