Make spaghetti-code-quality great again.
authorEdouard Tisserant
Fri, 22 Mar 2019 13:45:19 +0100
changeset 2551 245644bfcd24
parent 2550 f2af2a655868
child 2552 46a1e8d1e92c
Make spaghetti-code-quality great again.
BeremizIDE.py
ConfigTreeNode.py
PLCControler.py
controls/SearchResultPanel.py
editors/CodeFileEditor.py
xmlclass/xmlclass.py
--- a/BeremizIDE.py	Fri Mar 22 13:26:31 2019 +0100
+++ b/BeremizIDE.py	Fri Mar 22 13:45:19 2019 +0100
@@ -1034,11 +1034,11 @@
                 IDEFrame.ProjectTreeItemSelect(self, select_item)
 
     def GetProjectElementWindow(self, element, tagname):
-        is_a_CTN_tagname = len(tagname.split("::"))==1
+        is_a_CTN_tagname = len(tagname.split("::")) == 1
         if is_a_CTN_tagname:
             confnode = self.CTR.GetChildByName(tagname)
-            return confnode.GetView() 
-        else :
+            return confnode.GetView()
+        else:
             return IDEFrame.GetProjectElementWindow(self, element, tagname)
 
     def SelectProjectTreeItem(self, tagname):
--- a/ConfigTreeNode.py	Fri Mar 22 13:26:31 2019 +0100
+++ b/ConfigTreeNode.py	Fri Mar 22 13:45:19 2019 +0100
@@ -37,6 +37,7 @@
 import types
 import shutil
 from operator import add
+from functools import reduce
 from builtins import str as text
 from past.builtins import execfile
 
--- a/PLCControler.py	Fri Mar 22 13:26:31 2019 +0100
+++ b/PLCControler.py	Fri Mar 22 13:45:19 2019 +0100
@@ -2749,8 +2749,8 @@
     # -------------------------------------------------------------------------------
 
     def SearchInProject(self, criteria):
-        project_matches =  self.Project.Search(criteria)
-        ctn_matches =  self.CTNSearch(criteria)
+        project_matches = self.Project.Search(criteria)
+        ctn_matches = self.CTNSearch(criteria)
         return project_matches + ctn_matches
 
     def SearchInPou(self, tagname, criteria, debug=False):
--- a/controls/SearchResultPanel.py	Fri Mar 22 13:26:31 2019 +0100
+++ b/controls/SearchResultPanel.py	Fri Mar 22 13:45:19 2019 +0100
@@ -131,8 +131,7 @@
                 ("ACTION",         "action_block"),
                 ("IL",             "IL"),
                 ("ST",             "ST"),
-                ("FILE",           ITEM_CONFNODE),
-                ]:
+                ("FILE",           ITEM_CONFNODE)]:
             self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname))
 
         for itemtype in ["function", "functionBlock", "program",
@@ -205,10 +204,10 @@
                 children = element_infos.setdefault("children", [])
                 for infos, start, end, text in results:
                     if len(words) == 1:  # CTN match
-                        child_name = {"body":str(start[0])+":",
-                                      "var_inout":_("Variable:")}[infos[1]]
-                        child_type = {"body":ITEM_CONFNODE,
-                                      "var_inout":"var_inout"}[infos[1]]
+                        child_name = {"body": str(start[0])+":",
+                                      "var_inout": _("Variable:")}[infos[1]]
+                        child_type = {"body": ITEM_CONFNODE,
+                                      "var_inout": "var_inout"}[infos[1]]
                     elif infos[1] == "name" or element_type == ITEM_DATATYPE:
                         child_name = GenerateName(infos[1:])
                         child_type = element_type
--- a/editors/CodeFileEditor.py	Fri Mar 22 13:26:31 2019 +0100
+++ b/editors/CodeFileEditor.py	Fri Mar 22 13:45:19 2019 +0100
@@ -71,6 +71,7 @@
                 text += "\n"
     return text
 
+
 class CodeEditor(CustomStyledTextCtrl):
 
     KEYWORDS = []
@@ -255,8 +256,8 @@
 
     def GetCodeText(self):
         return GetSectionsText(
-            self.Controler, 
-            lambda section : self.SectionsComments[section]["comment"])
+            self.Controler,
+            lambda section: self.SectionsComments[section]["comment"])
 
     def RefreshView(self, scroll_to_highlight=False):
         self.ResetBuffer()
@@ -885,6 +886,7 @@
 #                          CodeFileEditor Main Frame Class
 # -------------------------------------------------------------------------------
 
+
 class CodeFileEditor(ConfTreeNodeEditor):
 
     CONFNODEEDITOR_TABS = []
--- a/xmlclass/xmlclass.py	Fri Mar 22 13:26:31 2019 +0100
+++ b/xmlclass/xmlclass.py	Fri Mar 22 13:45:19 2019 +0100
@@ -28,11 +28,11 @@
 import os
 import re
 import datetime
+from functools import reduce
 from xml.dom import minidom
 from xml.sax.saxutils import unescape
 from collections import OrderedDict
 from builtins import str as text
-from functools import reduce
 
 from six import string_types
 from six.moves import xrange