clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 15 Aug 2017 17:01:51 +0300
changeset 1743 c3c3d1318130
parent 1742 92932cd370a4
child 1744 69dfdb26f600
clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
IDEFrame.py
PLCControler.py
PLCGenerator.py
canfestival/config_utils.py
docutil/docpdf.py
editors/CodeFileEditor.py
editors/ConfTreeNodeEditor.py
editors/SFCViewer.py
editors/TextViewer.py
editors/Viewer.py
graphics/GraphicCommons.py
graphics/LD_Objects.py
graphics/RubberBand.py
graphics/SFC_Objects.py
plcopen/structures.py
runtime/PLCObject.py
svgui/pyjs/pyjs.py
util/Zeroconf.py
xmlclass/xmlclass.py
xmlclass/xsdschema.py
--- a/IDEFrame.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/IDEFrame.py	Tue Aug 15 17:01:51 2017 +0300
@@ -315,7 +315,7 @@
                 split_rect = wx.Rect(rect.x, rect.y,
                                      rect.width - tab["size"][0] - TAB_BORDER, rect.height)
             break
-    if split != None:
+    if split is not None:
         split_tab = tabs.pop(idx)
         return {"split": split,
                 "tab": split_tab,
--- a/PLCControler.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/PLCControler.py	Tue Aug 15 17:01:51 2017 +0300
@@ -2480,7 +2480,7 @@
                 result = wire.GetConnectedInfos(-1)
             else:
                 result = wire.GetConnectedInfos(0)
-            if result != None:
+            if result is not None:
                 refLocalId, formalParameter = result
                 connections = connection.getconnections()
                 if connections is None or len(connection.getconnections()) <= idx:
--- a/PLCGenerator.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/PLCGenerator.py	Tue Aug 15 17:01:51 2017 +0300
@@ -1224,7 +1224,7 @@
             elif isinstance(next, ContinuationClass):
                 name = next.getname()
                 computed_value = self.ComputedConnectors.get(name, None)
-                if computed_value != None:
+                if computed_value is not None:
                     paths.append(str(computed_value))
                 else:
                     connector = None
@@ -1587,7 +1587,7 @@
         if transition in self.SFCNetworks["Transitions"].keys():
             transition_infos = self.SFCNetworks["Transitions"].pop(transition)
             self.Program += [("%sTRANSITION" % self.CurrentIndent, ())]
-            if transition_infos["priority"] != None:
+            if transition_infos["priority"] is not None:
                 self.Program += [(" (PRIORITY := ", ()),
                                  ("%d" % transition_infos["priority"], (self.TagName, "transition", transition_infos["id"], "priority")),
                                  (")", ())]
@@ -1645,13 +1645,13 @@
                 if var_name:
                     program += [(var_name, (self.TagName, variable_type, var_number, "name")),
                                 (" ", ())]
-                if var_address != None:
+                if var_address is not None:
                     program += [("AT ", ()),
                                 (var_address, (self.TagName, variable_type, var_number, "location")),
                                 (" ", ())]
                 program += [(": ", ()),
                             (var_type, (self.TagName, variable_type, var_number, "type"))]
-                if var_initial != None:
+                if var_initial is not None:
                     program += [(" := ", ()),
                                 (self.ParentGenerator.ComputeValue(var_initial, var_type), (self.TagName, variable_type, var_number, "initial value"))]
                 program += [(";\n", ())]
--- a/canfestival/config_utils.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/canfestival/config_utils.py	Tue Aug 15 17:01:51 2017 +0300
@@ -117,7 +117,7 @@
 
     for PDOidx in GetNodePDOIndexes(node, loc_infos["pdotype"]):
         values = node.GetEntry(PDOidx)
-        if values != None:
+        if values is not None:
             for subindex, mapping in enumerate(values):
                 if subindex != 0 and mapping & 0xFFFFFF00 == model:
                     return PDOidx, subindex
@@ -266,7 +266,7 @@
         nodeDCF = self.MasterNode.GetEntry(0x1F22, nodeid)
 
         # Extract data and number of params in current DCF
-        if nodeDCF != None and nodeDCF != '':
+        if nodeDCF is not None and nodeDCF != '':
             tmpnbparams = [i for i in nodeDCF[:4]]
             tmpnbparams.reverse()
             nbparams += int(''.join(["%2.2x" % ord(i) for i in tmpnbparams]), 16)
@@ -295,7 +295,7 @@
         # starting from start_index
         while index < PDOTypeBaseIndex[pdotype] + 0x200:
             values = self.NodeList.GetSlaveNodeEntry(nodeid, index + 0x200)
-            if values != None and values[0] > 0:
+            if values is not None and values[0] > 0:
                 # Check that all subindex upper than 0 equal 0 => configurable PDO
                 if reduce(lambda x, y: x and y, map(lambda x: x == 0, values[1:]), True):
                     cobid = self.NodeList.GetSlaveNodeEntry(nodeid, index, 1)
@@ -420,7 +420,7 @@
 
             # Search if slave has a PDO mapping this locations
             result = SearchNodePDOMapping(locationinfos, node)
-            if result != None:
+            if result is not None:
                 index, subindex = result
                 # Get COB ID of the PDO
                 cobid = self.NodeList.GetSlaveNodeEntry(locationinfos["nodeid"], index - 0x200, 1)
@@ -593,7 +593,7 @@
                     # Verify that a not full entry has been found
                     if mapvariableidx < VariableStartIndex[variable_infos["pdotype"]] + 0x2000:
                         # Generate subentry name
-                        if variable_infos["bit"] != None:
+                        if variable_infos["bit"] is not None:
                             subindexname = "%(index)d_%(subindex)d_%(bit)d" % variable_infos
                         else:
                             subindexname = "%(index)d_%(subindex)d" % variable_infos
@@ -607,7 +607,7 @@
 
                         # Set value of the PDO mapping
                         typeinfos = self.Manager.GetEntryInfos(typeidx)
-                        if typeinfos != None:
+                        if typeinfos is not None:
                             value = (mapvariableidx << 16) + ((nbsubentries) << 8) + typeinfos["size"]
                             self.MasterNode.SetEntry(current_idx + 0x200, subindex, value)
 
--- a/docutil/docpdf.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/docutil/docpdf.py	Tue Aug 15 17:01:51 2017 +0300
@@ -48,14 +48,14 @@
 
 
 def open_win_pdf(readerexepath, pdffile, pagenum = None):
-    if pagenum != None:
+    if pagenum is not None:
         os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", "/A", "page=%d=OpenActions" % pagenum, '"%s"' % pdffile)
     else:
         os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"' % pdffile)
 
 
 def open_lin_pdf(readerexepath, pdffile, pagenum = None):
-    if pagenum == None:
+    if pagenum is None:
         os.system("%s -remote DS301 %s &" % (readerexepath, pdffile))
     else:
         print "Open pdf %s at page %d" % (pdffile, pagenum)
--- a/editors/CodeFileEditor.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/editors/CodeFileEditor.py	Tue Aug 15 17:01:51 2017 +0300
@@ -173,7 +173,7 @@
             mod_type = event.GetModificationType()
             if not (mod_type&wx.stc.STC_PERFORMED_UNDO or mod_type&wx.stc.STC_PERFORMED_REDO):
                 if mod_type&wx.stc.STC_MOD_BEFOREINSERT:
-                    if self.CurrentAction == None:
+                    if self.CurrentAction is None:
                         self.StartBuffering()
                     elif self.CurrentAction[0] != "Add" or self.CurrentAction[1] != event.GetPosition() - 1:
                         self.Controler.EndBuffering()
@@ -181,7 +181,7 @@
                     self.CurrentAction = ("Add", event.GetPosition())
                     wx.CallAfter(self.RefreshModel)
                 elif mod_type&wx.stc.STC_MOD_BEFOREDELETE:
-                    if self.CurrentAction == None:
+                    if self.CurrentAction is None:
                         self.StartBuffering()
                     elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1:
                         self.Controler.EndBuffering()
@@ -227,7 +227,7 @@
             self.ParentWindow.RefreshPageTitles()
 
     def ResetBuffer(self):
-        if self.CurrentAction != None:
+        if self.CurrentAction is not None:
             self.Controler.EndBuffering()
             self.CurrentAction = None
 
@@ -259,7 +259,7 @@
             self.SetText(new_text)
             new_cursor_pos = GetCursorPos(old_text, new_text)
             self.LineScroll(column, line)
-            if new_cursor_pos != None:
+            if new_cursor_pos is not None:
                 self.GotoPos(new_cursor_pos)
             else:
                 self.GotoPos(old_cursor_pos)
--- a/editors/ConfTreeNodeEditor.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/editors/ConfTreeNodeEditor.py	Tue Aug 15 17:01:51 2017 +0300
@@ -72,7 +72,7 @@
 
     def DrawLabel(self, dc, width, height, dw=0, dy=0):
         bmp = self.bmpLabel
-        if bmp != None:     # if the bitmap is used
+        if bmp is not None:     # if the bitmap is used
             if self.bmpDisabled and not self.IsEnabled():
                 bmp = self.bmpDisabled
             if self.bmpFocus and self.hasFocus:
@@ -82,7 +82,7 @@
             bw, bh = bmp.GetWidth(), bmp.GetHeight()
             if not self.up:
                 dw = dy = self.labelDelta
-            hasMask = bmp.GetMask() != None
+            hasMask = bmp.GetMask() is not None
         else:
             bw = bh = 0     # no bitmap -> size is zero
 
@@ -99,7 +99,7 @@
 
         pos_x = (width-bw)/2+dw      # adjust for bitmap and text to centre
         pos_y = (height-bh-th)/2+dy
-        if bmp != None:
+        if bmp is not None:
             dc.DrawBitmap(bmp, pos_x, pos_y, hasMask)  # draw bitmap if available
             pos_x = (width-tw)/2+dw      # adjust for bitmap and text to centre
             pos_y += bh + 2
--- a/editors/SFCViewer.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/editors/SFCViewer.py	Tue Aug 15 17:01:51 2017 +0300
@@ -342,7 +342,7 @@
 
     # This method check the IEC 61131-3 compatibility between two SFC blocks
     def BlockCompatibility(self, startblock = None, endblock = None, direction = None):
-        if startblock != None and endblock != None and (isinstance(startblock, SFC_Objects)\
+        if startblock is not None and endblock is not None and (isinstance(startblock, SFC_Objects)\
                                                                or isinstance(endblock, SFC_Objects)):
             # Full "SFC_StandardRules" table would be symmetrical and
             # to avoid duplicate records and minimize the table only upper part is defined.
--- a/editors/TextViewer.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/editors/TextViewer.py	Tue Aug 15 17:01:51 2017 +0300
@@ -226,7 +226,7 @@
         if not self.DisableEvents:
             mod_type = event.GetModificationType()
             if mod_type&wx.stc.STC_MOD_BEFOREINSERT:
-                if self.CurrentAction == None:
+                if self.CurrentAction is None:
                     self.StartBuffering()
                 elif self.CurrentAction[0] != "Add" or self.CurrentAction[1] != event.GetPosition() - 1:
                     self.Controler.EndBuffering()
@@ -234,7 +234,7 @@
                 self.CurrentAction = ("Add", event.GetPosition())
                 wx.CallAfter(self.RefreshModel)
             elif mod_type&wx.stc.STC_MOD_BEFOREDELETE:
-                if self.CurrentAction == None:
+                if self.CurrentAction is None:
                     self.StartBuffering()
                 elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1:
                     self.Controler.EndBuffering()
@@ -436,7 +436,7 @@
             self.ParentWindow.RefreshEditMenu()
 
     def ResetBuffer(self):
-        if self.CurrentAction != None:
+        if self.CurrentAction is not None:
             self.Controler.EndBuffering()
             self.CurrentAction = None
 
@@ -475,7 +475,7 @@
                 self.SetText(new_text)
                 new_cursor_pos = GetCursorPos(old_text, new_text)
                 self.Editor.LineScroll(column, line)
-                if new_cursor_pos != None:
+                if new_cursor_pos is not None:
                     self.Editor.GotoPos(new_cursor_pos)
                 else:
                     self.Editor.GotoPos(old_cursor_pos)
--- a/editors/Viewer.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/editors/Viewer.py	Tue Aug 15 17:01:51 2017 +0300
@@ -49,7 +49,7 @@
 
 def ResetCursors():
     global CURSORS
-    if CURSORS == None:
+    if CURSORS is None:
         CURSORS = [wx.NullCursor,
                    wx.StockCursor(wx.CURSOR_HAND),
                    wx.StockCursor(wx.CURSOR_SIZENWSE),
@@ -2321,7 +2321,7 @@
                 if self.DrawingWire:
                     connector, errorHighlight = self.FindBlockConnectorWithError(pos, self.SelectedElement.GetConnectionDirection(), self.SelectedElement.EndConnected)
                     self.SelectedElement.ErrHighlight = errorHighlight;
-                    if not connector or self.SelectedElement.EndConnected == None:
+                    if not connector or self.SelectedElement.EndConnected is None:
                         self.SelectedElement.ResetPoints()
                         movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
                         self.SelectedElement.GeneratePoints()
@@ -2966,7 +2966,7 @@
             "name": step.GetName(),
             "input": len(connectors["inputs"]) > 0,
             "output": len(connectors["outputs"]) > 0,
-            "action": step.GetActionConnector() != None})
+            "action": step.GetActionConnector() is not None})
         if dialog.ShowModal() == wx.ID_OK:
             values = dialog.GetValues()
             rect = step.GetRedrawRect(1, 1)
--- a/graphics/GraphicCommons.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/graphics/GraphicCommons.py	Tue Aug 15 17:01:51 2017 +0300
@@ -1813,7 +1813,7 @@
         if segment == -1:
             segment = len(self.Segments) - 1
         # The selected segment is reinitialised
-        if segment == None:
+        if segment is None:
             if self.StartConnected:
                 self.StartConnected.SetSelected(False)
             if self.EndConnected:
@@ -2022,13 +2022,13 @@
 
     # Returns the position of the two selected segment points
     def GetSelectedSegmentPoints(self):
-        if self.SelectedSegment != None and len(self.Points) > 1:
+        if self.SelectedSegment is not None and len(self.Points) > 1:
             return self.Points[self.SelectedSegment:self.SelectedSegment + 2]
         return []
 
     # Returns if the selected segment is the first and/or the last of the wire
     def GetSelectedSegmentConnections(self):
-        if self.SelectedSegment != None and len(self.Points) > 1:
+        if self.SelectedSegment is not None and len(self.Points) > 1:
             return self.SelectedSegment == 0, self.SelectedSegment == len(self.Segments) - 1
         return (True, True)
 
@@ -2436,7 +2436,7 @@
         #else:
         # Test if a segment have been handled
         result = self.TestSegment(pos)
-        if result != None:
+        if result is not None:
             if result[1] in (NORTH, SOUTH):
                 wx.CallAfter(self.Parent.SetCurrentCursor, 4)
             elif result[1] in (EAST, WEST):
@@ -2452,7 +2452,7 @@
         pos = GetScaledEventPosition(event, dc, scaling)
         # Test if a segment has been handled
         result = self.TestSegment(pos, True)
-        if result != None:
+        if result is not None:
             self.Handle = (HANDLE_SEGMENT, result)
             # Popup the menu with special items for a wire
             self.Parent.PopupWireMenu(0 < result[0] < len(self.Segments) - 1)
@@ -2617,7 +2617,7 @@
         self.OverEnd = False
         # Test if a point has been handled
         result = self.TestPoint(pos)
-        if result != None:
+        if result is not None:
             if result == 0 and self.StartConnected is not None:
                 self.OverStart = True
             elif result != 0 and self.EndConnected is not None:
--- a/graphics/LD_Objects.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/graphics/LD_Objects.py	Tue Aug 15 17:01:51 2017 +0300
@@ -92,7 +92,7 @@
     # Forbids to select a power rail
     def HitTest(self, pt, connectors=True):
         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
-            return Graphic_Element.HitTest(self, pt, connectors) or self.TestConnector(pt, exclude=False) != None
+            return Graphic_Element.HitTest(self, pt, connectors) or self.TestConnector(pt, exclude=False) is not None
         return False
 
     # Forbids to select a power rail
--- a/graphics/RubberBand.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/graphics/RubberBand.py	Tue Aug 15 17:01:51 2017 +0300
@@ -61,7 +61,7 @@
         Indicate if rubberband is drawn on viewer
         @return: True if rubberband is drawn
         """
-        return self.CurrentBBox != None
+        return self.CurrentBBox is not None
 
     def GetCurrentExtent(self):
         """
--- a/graphics/SFC_Objects.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/graphics/SFC_Objects.py	Tue Aug 15 17:01:51 2017 +0300
@@ -820,12 +820,12 @@
             if type == "connection":
                 self.Condition = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2), WEST)
             else:
-                if condition == None:
+                if condition is None:
                     condition = ""
                 self.Condition = condition
                 self.RefreshConditionSize()
         elif self.Type != "connection":
-            if condition == None:
+            if condition is None:
                 condition = ""
             self.Condition = condition
             self.RefreshConditionSize()
@@ -1197,7 +1197,7 @@
 
     # Returns if the point given is in the bounding box
     def HitTest(self, pt, connectors=True):
-        return self.BoundingBox.InsideXY(pt.x, pt.y) or self.TestConnector(pt, exclude=False) != None
+        return self.BoundingBox.InsideXY(pt.x, pt.y) or self.TestConnector(pt, exclude=False) is not None
 
     # Refresh the divergence bounding box
     def RefreshBoundingBox(self):
--- a/plcopen/structures.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/plcopen/structures.py	Tue Aug 15 17:01:51 2017 +0300
@@ -212,7 +212,7 @@
                 funcdeclname = Function_decl["name"].strip('*_')
                 fdc = Function_decl["inputs"][:]
                 for intype in input_ovrloading_types:
-                    if intype != None:
+                    if intype is not None:
                         Function_decl["inputs"] = []
                         for decl_tpl in fdc:
                             if IsOfType(intype, decl_tpl[1]):
@@ -228,7 +228,7 @@
                         funcdeclin = funcdeclname
 
                     for outype in output_types:
-                        if outype != None:
+                        if outype is not None:
                             decl_tpl = Function_decl["outputs"][0]
                             Function_decl["outputs"] = [ (decl_tpl[0], outype,  decl_tpl[2])]
                             if funcdeclname_orig.endswith('*'):
--- a/runtime/PLCObject.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/runtime/PLCObject.py	Tue Aug 15 17:01:51 2017 +0300
@@ -477,7 +477,7 @@
                 # keep a copy of requested idx
                 self._ResetDebugVariables()
                 for idx, iectype, force in idxs:
-                    if force != None:
+                    if force is not None:
                         c_type, unpack_func, pack_func = \
                             TypeTranslator.get(iectype,
                                                     (None, None, None))
--- a/svgui/pyjs/pyjs.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/svgui/pyjs/pyjs.py	Tue Aug 15 17:01:51 2017 +0300
@@ -595,7 +595,7 @@
         if expr:
             #print >> self.output, "} else { throw(%s); } " % errName
             print >> self.output, "}"
-        if node.else_ != None:
+        if node.else_ is not None:
             print >>self.output, "    } finally {"
             for stmt in node.else_:
                 self._stmt(stmt, current_klass)
@@ -607,7 +607,7 @@
         attr_name = v.attrname
         if isinstance(v.expr, ast.Name):
             obj = self._name(v.expr, current_klass, return_none_for_module=True)
-            if obj == None and v.expr.name in self.module_imports():
+            if obj is None and v.expr.name in self.module_imports():
                 # XXX TODO: distinguish between module import classes
                 # and variables.  right now, this is a hack to get
                 # the sys module working.
@@ -1027,7 +1027,7 @@
         lineNum = "Unknown"
         srcLine = ""
         if hasattr(node, "lineno"):
-            if node.lineno != None:
+            if node.lineno is not None:
                 lineNum = node.lineno
                 srcLine = self.src[min(lineNum, len(self.src))-1]
                 srcLine = srcLine.replace('\\', '\\\\')
@@ -1445,9 +1445,9 @@
         if node.flags == "OP_APPLY":
             lower = "null"
             upper = "null"
-            if node.lower != None:
+            if node.lower is not None:
                 lower = self.expr(node.lower, current_klass)
-            if node.upper != None:
+            if node.upper is not None:
                 upper = self.expr(node.upper, current_klass)
             return "pyjslib.slice(" + self.expr(node.expr, current_klass) + ", " + lower + ", " + upper + ")"
         else:
--- a/util/Zeroconf.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/util/Zeroconf.py	Tue Aug 15 17:01:51 2017 +0300
@@ -1120,7 +1120,7 @@
                         value = 0
 
                 # Only update non-existent properties
-                if key and result.get(key) == None:
+                if key and result.get(key) is None:
                     result[key] = value
 
             self.properties = result
--- a/xmlclass/xmlclass.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/xmlclass/xmlclass.py	Tue Aug 15 17:01:51 2017 +0300
@@ -596,7 +596,7 @@
         "extract": ExtractTag,
         "generate": GenerateTag,
         "initial": lambda: None,
-        "check": lambda x: x == None or infos["minOccurs"] == 0 and value == True
+        "check": lambda x: x is None or infos["minOccurs"] == 0 and value == True
     }
 
 
@@ -1535,7 +1535,7 @@
                     if instance is None and elements[parts[0]]["minOccurs"] == 0:
                         instance = elements[parts[0]]["elmt_type"]["initial"]()
                         setattr(self, parts[0], instance)
-                    if instance != None:
+                    if instance is not None:
                         if len(parts) > 1:
                             instance.setElementValue(parts[1], value)
                         else:
--- a/xmlclass/xsdschema.py	Tue Aug 15 16:48:49 2017 +0300
+++ b/xmlclass/xsdschema.py	Tue Aug 15 17:01:51 2017 +0300
@@ -992,7 +992,7 @@
             return False
         for name, value in schema.items():
             ref_value = reference.get(name, None)
-            if ref_value is None and value != None:
+            if ref_value is None and value is not None:
                 return False
             result = CompareSchema(value, ref_value)
             if not result: