# HG changeset patch # User Andrey Skvortsov # Date 1507716921 -10800 # Node ID 616c3f4bcbcb9f75a88695d1e6c814654b74d58b # Parent 418777c1fbc7d4e5ceb21ab1990156fb564d991d fix pylint error '(no-self-argument) Method should have "self" as first argument' diff -r 418777c1fbc7 -r 616c3f4bcbcb ConfigTreeNode.py --- a/ConfigTreeNode.py Wed Oct 11 11:54:55 2017 +0300 +++ b/ConfigTreeNode.py Wed Oct 11 13:15:21 2017 +0300 @@ -547,55 +547,54 @@ This way __init__ is overloaded to ensure ConfigTreeNode.__init__ is called before CTNClass.__init__, and to do the file related stuff. """ - def __init__(_self): - # self is the parent - _self.CTNParent = self + def __init__(self, parent): + self.CTNParent = parent # Keep track of the confnode type name - _self.CTNType = CTNType + self.CTNType = CTNType # remind the help string, for more fancy display - _self.CTNHelp = CTNHelp + self.CTNHelp = CTNHelp # Call the base confnode template init - change XSD into class members - ConfigTreeNode.__init__(_self) + ConfigTreeNode.__init__(self) # check name is unique - NewCTNName = _self.FindNewName(CTNName) + NewCTNName = self.FindNewName(CTNName) # If dir have already be made, and file exist - if os.path.isdir(_self.CTNPath(NewCTNName)): # and os.path.isfile(_self.ConfNodeXmlFilePath(CTNName)): + if os.path.isdir(self.CTNPath(NewCTNName)): # and os.path.isfile(self.ConfNodeXmlFilePath(CTNName)): # Load the confnode.xml file into parameters members - _self.LoadXMLParams(NewCTNName) + self.LoadXMLParams(NewCTNName) # Basic check. Better to fail immediately. - if _self.BaseParams.getName() != NewCTNName: + if self.BaseParams.getName() != NewCTNName: raise Exception( _("Project tree layout do not match confnode.xml {a1}!={a2} "). - format(a1=NewCTNName, a2=_self.BaseParams.getName())) + format(a1=NewCTNName, a2=self.BaseParams.getName())) # Now, self.CTNPath() should be OK # Check that IEC_Channel is not already in use. - _self.FindNewIEC_Channel(_self.BaseParams.getIEC_Channel()) + self.FindNewIEC_Channel(self.BaseParams.getIEC_Channel()) # Call the confnode real __init__ if getattr(CTNClass, "__init__", None): - CTNClass.__init__(_self) + CTNClass.__init__(self) # Load and init all the children - _self.LoadChildren() + self.LoadChildren() # just loaded, nothing to saved - _self.ChangesToSave = False + self.ChangesToSave = False else: # If confnode do not have corresponding file/dirs - they will be created on Save - _self.CTNMakeDir() + self.CTNMakeDir() # Find an IEC number - _self.FindNewIEC_Channel(IEC_Channel) + self.FindNewIEC_Channel(IEC_Channel) # Call the confnode real __init__ if getattr(CTNClass, "__init__", None): - CTNClass.__init__(_self) - _self.CTNRequestSave() + CTNClass.__init__(self) + self.CTNRequestSave() # just created, must be saved - _self.ChangesToSave = True - - def _getBuildPath(_self): - return self._getBuildPath() + self.ChangesToSave = True + + def _getBuildPath(self): + return self.CTNParent._getBuildPath() # Create the object out of the resulting class - newConfNodeOpj = FinalCTNClass() + newConfNodeOpj = FinalCTNClass(self) # Store it in CTNgedChils ChildrenWithSameClass.append(newConfNodeOpj) diff -r 418777c1fbc7 -r 616c3f4bcbcb graphics/GraphicCommons.py --- a/graphics/GraphicCommons.py Wed Oct 11 11:54:55 2017 +0300 +++ b/graphics/GraphicCommons.py Wed Oct 11 13:15:21 2017 +0300 @@ -916,7 +916,7 @@ self.Size = wx.Size(self.BoundingBox.width, self.BoundingBox.height) # Forbids to change the group position - def SetPosition(x, y): + def SetPosition(self, x, y): pass # Returns the position of this group @@ -937,7 +937,7 @@ return self.BoundingBox.x, self.BoundingBox.y # Forbids to change the group size - def SetSize(width, height): + def SetSize(self, width, height): pass # Returns the size of this group @@ -1640,11 +1640,11 @@ return None # Forbids to change the wire position - def SetPosition(x, y): + def SetPosition(self, x, y): pass # Forbids to change the wire size - def SetSize(width, height): + def SetSize(self, width, height): pass # Moves and Resizes the element for fitting scaling diff -r 418777c1fbc7 -r 616c3f4bcbcb runtime/PLCObject.py --- a/runtime/PLCObject.py Wed Oct 11 11:54:55 2017 +0300 +++ b/runtime/PLCObject.py Wed Oct 11 13:15:21 2017 +0300 @@ -277,24 +277,25 @@ MethodNames = ["init", "start", "stop", "cleanup"] self.python_runtime_vars = globals().copy() self.python_runtime_vars.update(self.pyruntimevars) + parent = self class PLCSafeGlobals(object): - def __getattr__(_self, name): + def __getattr__(self, name): try: - t = self.python_runtime_vars["_"+name+"_ctype"] + t = parent.python_runtime_vars["_"+name+"_ctype"] except KeyError: raise KeyError("Try to get unknown shared global variable : %s" % name) v = t() - self.python_runtime_vars["_PySafeGetPLCGlob_"+name](ctypes.byref(v)) - return self.python_runtime_vars["_"+name+"_unpack"](v) - - def __setattr__(_self, name, value): + parent.python_runtime_vars["_PySafeGetPLCGlob_"+name](ctypes.byref(v)) + return parent.python_runtime_vars["_"+name+"_unpack"](v) + + def __setattr__(self, name, value): try: - t = self.python_runtime_vars["_"+name+"_ctype"] + t = parent.python_runtime_vars["_"+name+"_ctype"] except KeyError: raise KeyError("Try to set unknown shared global variable : %s" % name) - v = self.python_runtime_vars["_"+name+"_pack"](t, value) - self.python_runtime_vars["_PySafeSetPLCGlob_"+name](ctypes.byref(v)) + v = parent.python_runtime_vars["_"+name+"_pack"](t, value) + parent.python_runtime_vars["_PySafeSetPLCGlob_"+name](ctypes.byref(v)) self.python_runtime_vars.update({ "PLCGlobals": PLCSafeGlobals(), diff -r 418777c1fbc7 -r 616c3f4bcbcb tests/tools/check_source.sh --- a/tests/tools/check_source.sh Wed Oct 11 11:54:55 2017 +0300 +++ b/tests/tools/check_source.sh Wed Oct 11 13:15:21 2017 +0300 @@ -210,7 +210,16 @@ disable=$disable,C0301 # Line too long disable=$disable,C0302 # Too many lines in module disable=$disable,W0511 # fixme - + disable=$disable,R0901 # (too-many-ancestors) Too many ancestors (9/7) + disable=$disable,R0902 # (too-many-instance-attributes) Too many instance attributes (10/7) + disable=$disable,R0903 # (too-few-public-methods) Too few public methods (0/2) + disable=$disable,R0904 # (too-many-public-methods) Too many public methods (41/20) + disable=$disable,R0911 # (too-many-return-statements) Too many return statements (7/6) + disable=$disable,R0912 # (too-many-branches) Too many branches (61/12) + disable=$disable,R0913 # (too-many-arguments) Too many arguments (6/5) + disable=$disable,R0914 # (too-many-locals) Too many local variables (18/15) + disable=$disable,R0915 # (too-many-statements) Too many statements (57/50) + disable=$disable,R0916 # (too-many-boolean-expressions) Too many boolean expressions in if statement (6/5) enable= enable=$enable,E1601 # print statement used @@ -244,6 +253,7 @@ enable=$enable,E1120 # (no-value-for-parameter) No value for argument 'X' in function call enable=$enable,E0701 # (bad-except-order) Bad except clauses order (X is an ancestor class of Y) enable=$enable,E0611 # (no-name-in-module) No name 'X' in module 'Y' + enable=$enable,E0213 # (no-self-argument) Method should have "self" as first argument # enable= options=