cleanup etherlab: pep8, E265 block comment should start with '# '
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 28 Sep 2018 17:48:10 +0300
changeset 2356 c26e0c66d8d5
parent 2355 fec77f2b9e07
child 2357 7c67286cddbe
cleanup etherlab: pep8, E265 block comment should start with '# '
etherlab/CommonEtherCATFunction.py
etherlab/ConfigEditor.py
etherlab/EtherCATManagementEditor.py
etherlab/EthercatCIA402Slave.py
etherlab/EthercatMaster.py
etherlab/EthercatSlave.py
etherlab/etherlab.py
--- a/etherlab/CommonEtherCATFunction.py	Fri Sep 28 17:20:11 2018 +0300
+++ b/etherlab/CommonEtherCATFunction.py	Fri Sep 28 17:48:10 2018 +0300
@@ -44,9 +44,9 @@
                 return name.getcontent()
     return default
 
-#--------------------------------------------------
+# --------------------------------------------------
 #         Remote Exec Etherlab Commands
-#--------------------------------------------------
+# --------------------------------------------------
 
 # --------------------- for master ---------------------------
 MASTER_STATE = """
@@ -136,9 +136,9 @@
 returnVal =result
 """
 
-#--------------------------------------------------
+# --------------------------------------------------
 #    Common Method For EtherCAT Management
-#--------------------------------------------------
+# --------------------------------------------------
 class _CommonSlave:
 
     # ----- Data Structure for ethercat management ----
@@ -181,9 +181,9 @@
 
         self.ClearSDODataSet()
 
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     #                        Used Master State
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     def GetMasterState(self):
         """
         Execute "ethercat master" command and parse the execution result
@@ -207,9 +207,9 @@
 
         return master_state
 
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     #                        Used Slave State
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     def RequestSlaveState(self, command):
         """
         Set slave state to the specified one using "ethercat states -p %d %s" command.
@@ -228,9 +228,9 @@
         self.SlaveState = return_val
         return return_val
 
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     #                        Used SDO Management
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     def GetSlaveSDOFromSlave(self):
         """
         Get SDO objects information of current slave using "ethercat sdos -p %d" command.
@@ -270,9 +270,9 @@
         for count in range(6):
             self.SaveSDOData.append([])
 
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     #                        Used PDO Monitoring
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     def RequestPDOInfo(self):
         """
         Load slave information from RootClass (XML data) and parse the information (calling SlavePDOData() method).
@@ -397,9 +397,9 @@
         self.RxPDOInfos = []
         self.RxPDOCategorys = []
 
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     #                        Used EEPROM Management
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     # Base data types in ETG2000; format = {"Name": "BitSize"}
     BaseDataTypeDict = {"BOOL": "01",
                         "SINT": "02",
@@ -1519,9 +1519,9 @@
 
         return eeprom
 
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     #                        Used Register Access
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     def RegRead(self, offset, length):
         """
         Read slave ESC register content using "ethercat reg_read -p %d %s %s" command.
@@ -1551,9 +1551,9 @@
         """
         error, return_val = self.Controler.RemoteExec(RESCAN%(self.Controler.GetSlavePos()), return_val = None)
 
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     #                        Common Use Methods
-    #-------------------------------------------------------------------------------
+    # -------------------------------------------------------------------------------
     def CheckConnect(self, cyclic_flag):
         """
         Check connection status (1) between Beremiz and the master (2) between the master and the slave.
--- a/etherlab/ConfigEditor.py	Fri Sep 28 17:20:11 2018 +0300
+++ b/etherlab/ConfigEditor.py	Fri Sep 28 17:48:10 2018 +0300
@@ -1054,7 +1054,7 @@
                 maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, posx, posy)
         event.Skip()
 
-    #def OnButtonClick(self, event):
+    # def OnButtonClick(self, event):
     #    self.MasterState = self.Controler.getMasterState()
     #    if self.MasterState:
     #        self.Phase.SetValue(self.MasterState["phase"])
--- a/etherlab/EtherCATManagementEditor.py	Fri Sep 28 17:20:11 2018 +0300
+++ b/etherlab/EtherCATManagementEditor.py	Fri Sep 28 17:48:10 2018 +0300
@@ -21,11 +21,11 @@
 # ------------ for SDO Management --------------------
 import string
 import wx.grid as gridlib
-#-------------------------------------------------------------
+# -------------------------------------------------------------
 
 # ------------ for register management ---------------
 from xml.dom import minidom
-#-------------------------------------------------------------
+# -------------------------------------------------------------
 
 # ----------------------------- For Sync Manager Table -----------------------------------
 def GetSyncManagersTableColnames():
@@ -35,9 +35,9 @@
     _ = lambda x : x
     return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")]
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    Sync Managers Table
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class SyncManagersTable(CustomTable):
     def GetValue(self, row, col):
         if row < self.GetNumberRows():
@@ -45,9 +45,9 @@
                 return row
             return self.data[row].get(self.GetColLabelValue(col, False), "")
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    EtherCAT Management Treebook
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class EtherCATManagementTreebook(wx.Treebook):
     def __init__(self, parent, controler, node_editor):
         """
@@ -91,9 +91,9 @@
         sel = event.GetSelection()
         event.Skip()
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For SlaveState Panel
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class SlaveStatePanelClass(wx.Panel):
     def __init__(self, parent, controler):
         """
@@ -306,9 +306,9 @@
         except Exception:
             pass
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For SDO Management Panel
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class SDOPanelClass(wx.Panel):
     def __init__(self, parent, controler):
         """
@@ -446,8 +446,8 @@
         @return result : output data after check
         """
         # string.printable is print this result
-        #'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
-        #!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c
+        # '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
+        # !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c
         allow_range = string.printable
         result = check_string
         for i in range(0, len(check_string)):
@@ -458,9 +458,9 @@
         return result
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For SDO Notebook (divide category)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class SDONoteBook(wx.Notebook):
     def __init__(self, parent, controler):
         """
@@ -518,9 +518,9 @@
         sel = self.GetSelection()
         event.Skip()
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For SDO Grid (fill index, subindex, etc...)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class SlaveSDOTable(wx.grid.Grid):
     def __init__(self, parent, data):
         """
@@ -664,11 +664,11 @@
                     self.Controler.CommonMethod.CreateErrorDialog('You can input only hex, dec value')
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                 For PDO Monitoring Panel
 # PDO Class UI  : Panel -> Choicebook (RxPDO, TxPDO) ->
 #                 Notebook (PDO Index) -> Grid (PDO entry)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class PDOPanelClass(wx.Panel):
     def __init__(self, parent, controler):
         """
@@ -699,9 +699,9 @@
         self.Refresh()
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For PDO Choicebook (divide Tx, Rx PDO)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class PDOChoicebook(wx.Choicebook):
     def __init__(self, parent, controler):
         """
@@ -733,9 +733,9 @@
         event.Skip()
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For PDO Notebook (divide PDO index)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class PDONoteBook(wx.Notebook):
     def __init__(self, parent, name, controler):
         """
@@ -790,9 +790,9 @@
         event.Skip()
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For PDO Grid (fill entry index, subindex etc...)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class PDOEntryTable(wx.grid.Grid):
     def __init__(self, parent, info, entry, count):
         """
@@ -862,10 +862,10 @@
             start_value += 1
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For EEPROM Access Main Panel
 #                 (This class explain EEPROM Access)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class EEPROMAccessPanel(wx.Panel):
     def __init__(self, parent, controler):
         """
@@ -885,9 +885,9 @@
         self.SetSizer(sizer)
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For Smart View Panel
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class SlaveSiiSmartView(wx.Panel):
     def __init__(self, parent, controler):
         """
@@ -1163,9 +1163,9 @@
             ''.join(data)
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For Smart View TreeListCtrl
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class SmartViewTreeListCtrl(wx.Panel):
     def __init__(self, parent, Controler):
         """
@@ -1229,10 +1229,10 @@
             self.Tree.Expand(tree)
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                         For Hex View Panel
 #            shows EEPROM binary as hex data and characters.
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class HexView(wx.Panel):
     def __init__(self, parent, controler):
         """
@@ -1370,9 +1370,9 @@
         self.SiiGrid.Update()
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For Hex View grid (fill hex data)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class SiiGridTable(wx.grid.Grid):
     def __init__(self, parent, controler, row, col):
         """
@@ -1422,9 +1422,9 @@
             row = row + 1
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For Register Access Panel
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class RegisterAccessPanel(wx.Panel):
     def __init__(self, parent, controler):
         """
@@ -1494,9 +1494,9 @@
         Get data from the register.
         """
         self.Controler.CommonMethod.RegData = ""
-        #ethercat reg_read
-        #ex : ethercat reg_read -p 0 0x0000 0x0001
-        #return value : 0x11
+        # ethercat reg_read
+        # ex : ethercat reg_read -p 0 0x0000 0x0001
+        # return value : 0x11
         for index in range(4):
             self.Controler.CommonMethod.RegData = self.Controler.CommonMethod.RegData + " " + self.Controler.CommonMethod.RegRead("0x"+"{:0>4x}".format(index*1024), "0x0400")
 
@@ -1783,9 +1783,9 @@
                                                                       self.RegMonitorData)
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For Register Access Notebook (divide index range)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class RegisterNotebook(wx.Notebook):
     def __init__(self, parent, controler):
         """
@@ -1825,10 +1825,10 @@
         event.Skip()
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For Register Access Notebook Panel
 #                  (Main UI : including main, sub table)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class RegisterNotebookPanel(wx.Panel):
     def __init__(self, parent, controler, row, col):
         """
@@ -1894,9 +1894,9 @@
         self.SubTable.Update()
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For Register Access Notebook Panel (Main Table)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class RegisterMainTable(wx.grid.Grid):
     def __init__(self, parent, row, col, controler):
         """
@@ -2045,9 +2045,9 @@
                     self.Controler.CommonMethod.CreateErrorDialog('You entered wrong value. You can enter dec or hex value only.')
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For Register Access Notebook Panel (Sub Table)
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class RegisterSubTable(wx.grid.Grid):
     def __init__(self, parent, row, col):
         """
@@ -2091,9 +2091,9 @@
             row = row + 1
 
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                    For Master State Panel
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 class MasterStatePanelClass(wx.Panel):
     def __init__(self, parent, controler):
         """
--- a/etherlab/EthercatCIA402Slave.py	Fri Sep 28 17:20:11 2018 +0300
+++ b/etherlab/EthercatCIA402Slave.py	Fri Sep 28 17:48:10 2018 +0300
@@ -89,9 +89,9 @@
      "outputs": []},
 ]
 
-#--------------------------------------------------
+# --------------------------------------------------
 #                 Ethercat CIA402 Node
-#--------------------------------------------------
+# --------------------------------------------------
 
 class _EthercatCIA402SlaveCTN(_EthercatSlaveCTN):
     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
@@ -123,9 +123,9 @@
          "push": True},
     ]
 
-#--------------------------------------------------
+# --------------------------------------------------
 #    class code
-#--------------------------------------------------
+# --------------------------------------------------
 
     def __init__(self):
         # ----------- call ethercat mng. function --------------
--- a/etherlab/EthercatMaster.py	Fri Sep 28 17:20:11 2018 +0300
+++ b/etherlab/EthercatMaster.py	Fri Sep 28 17:48:10 2018 +0300
@@ -34,9 +34,9 @@
 except Exception:
     HAS_MCL = False
 
-#--------------------------------------------------
+# --------------------------------------------------
 #         Remote Exec Etherlab Commands
-#--------------------------------------------------
+# --------------------------------------------------
 
 SCAN_COMMAND = """
 import commands
@@ -64,9 +64,9 @@
 returnVal = slaves
 """
 
-#--------------------------------------------------
+# --------------------------------------------------
 #      Etherlab Specific Blocks Library
-#--------------------------------------------------
+# --------------------------------------------------
 
 def GetLocalPath(filename):
     return os.path.join(os.path.split(__file__)[0], filename)
@@ -89,9 +89,9 @@
         return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "",
                 ("runtime_etherlab.py", file(GetLocalPath("runtime_etherlab.py"))))
 
-#--------------------------------------------------
+# --------------------------------------------------
 #                 Ethercat MASTER
-#--------------------------------------------------
+# --------------------------------------------------
 
 EtherCATConfigParser = GenerateParserFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATConfig.xsd"))
 
@@ -571,7 +571,6 @@
                 device, module_extra_params = self.GetModuleInfos(type_infos)
         if device is not None:
             entries = device.GetEntriesList(limits)
-            #print entries
             entries_list = entries.items()
             entries_list.sort()
             entries = []
@@ -770,9 +769,9 @@
 
         return [],"",False
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                      Current Buffering Management Functions
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 
     """
     Return a copy of the config
--- a/etherlab/EthercatSlave.py	Fri Sep 28 17:20:11 2018 +0300
+++ b/etherlab/EthercatSlave.py	Fri Sep 28 17:48:10 2018 +0300
@@ -16,9 +16,9 @@
 
 from ConfigEditor import NodeEditor
 
-#------------------------------------------
+# ------------------------------------------
 from CommonEtherCATFunction import _CommonSlave
-#------------------------------------------
+# ------------------------------------------
 
 
 TYPECONVERSION = {"BOOL" : "X", "SINT" : "B", "INT" : "W", "DINT" : "D", "LINT" : "L",
@@ -59,9 +59,9 @@
     return default
 
 
-#--------------------------------------------------
+# --------------------------------------------------
 #                    Ethercat Node
-#--------------------------------------------------
+# --------------------------------------------------
 
 class _EthercatSlaveCTN:
     NODE_PROFILE = None
@@ -124,11 +124,11 @@
             self.CTNParent.SetSlaveType(position, value)
             slave_type = self.CTNParent.GetSlaveType(self.GetSlavePos())
             value = (slave_type["device_type"], slave_type)
-            #if self._View is not None:
-                #wx.CallAfter(self._View.EtherCATManagementTreebook.SlaveStatePanel.RefreshSlaveInfos())
-                #self._View.EtherCATManagementTreebook.SlaveStatePanel.RefreshSlaveInfos()
-                #self._View.EtherCATManagementTreebook.PDOMonitoringPanel.PDOInfoUpdate()
-                #self._View.EtherCATManagementTreebook.SmartView.Create_SmartView()
+            # if self._View is not None:
+            #     wx.CallAfter(self._View.EtherCATManagementTreebook.SlaveStatePanel.RefreshSlaveInfos())
+            #     self._View.EtherCATManagementTreebook.SlaveStatePanel.RefreshSlaveInfos()
+            #     self._View.EtherCATManagementTreebook.PDOMonitoringPanel.PDOInfoUpdate()
+            #     self._View.EtherCATManagementTreebook.SmartView.Create_SmartView()
             return value, True
         elif path == "SlaveParams.Alias":
             self.CTNParent.SetSlaveAlias(position, value)
--- a/etherlab/etherlab.py	Fri Sep 28 17:20:11 2018 +0300
+++ b/etherlab/etherlab.py	Fri Sep 28 17:48:10 2018 +0300
@@ -26,9 +26,9 @@
 
 ScriptDirectory = os.path.split(os.path.realpath(__file__))[0]
 
-#--------------------------------------------------
+# --------------------------------------------------
 #                 Ethercat ConfNode
-#--------------------------------------------------
+# --------------------------------------------------
 
 EtherCATInfoParser = GenerateParserFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATInfo.xsd"))
 EtherCATInfo_XPath = lambda xpath: etree.XPath(xpath)
@@ -223,9 +223,9 @@
                             {"name": ExtractName(group.getName(), group_type),
                              "parent": group.getParentGroup(),
                              "order": group.getSortOrder(),
-                             #"value": group.getcontent()["value"],
+                             # "value": group.getcontent()["value"],
                              "devices": []})
-
+                             
                     for device in self.devices_xpath(self.modules_infos):
                         device_group = device.getGroupType()
                         if not vendor_category["groups"].has_key(device_group):