clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
--- 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)
split_tab = tabs.pop(idx)
--- 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)
result = wire.GetConnectedInfos(0)
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):
computed_value = self.ComputedConnectors.get(name, None)
- if computed_value != None:
+ if computed_value is not None: paths.append(str(computed_value))
@@ -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 @@
program += [(var_name, (self.TagName, variable_type, var_number, "name")),
- if var_address != None:
+ if var_address is not None: (var_address, (self.TagName, variable_type, var_number, "location")),
(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"))]
--- 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)
for subindex, mapping in enumerate(values):
if subindex != 0 and mapping & 0xFFFFFF00 == model:
@@ -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]]
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)
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:
- if variable_infos["bit"] != None:
+ if variable_infos["bit"] is not None: subindexname = "%(index)d_%(subindex)d_%(bit)d" % variable_infos
subindexname = "%(index)d_%(subindex)d" % variable_infos
@@ -607,7 +607,7 @@
# Set value of the PDO mapping
typeinfos = self.Manager.GetEntryInfos(typeidx)
+ 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 is not None: os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", "/A", "page=%d=OpenActions" % pagenum, '"%s"' % pdffile)
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"' % pdffile)
def open_lin_pdf(readerexepath, pdffile, pagenum = None):
os.system("%s -remote DS301 %s &" % (readerexepath, pdffile))
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: 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: elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1:
self.Controler.EndBuffering()
@@ -227,7 +227,7 @@
self.ParentWindow.RefreshPageTitles()
- if self.CurrentAction != None:
+ if self.CurrentAction is not None: self.Controler.EndBuffering()
self.CurrentAction = None
@@ -259,7 +259,7 @@
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)
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):
- 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():
if self.bmpFocus and self.hasFocus:
@@ -82,7 +82,7 @@
bw, bh = bmp.GetWidth(), bmp.GetHeight()
dw = dy = self.labelDelta
- hasMask = bmp.GetMask() != None
+ hasMask = bmp.GetMask() is not None 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
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
--- 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: 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: elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1:
self.Controler.EndBuffering()
@@ -436,7 +436,7 @@
self.ParentWindow.RefreshEditMenu()
- if self.CurrentAction != None:
+ if self.CurrentAction is not None: self.Controler.EndBuffering()
self.CurrentAction = None
@@ -475,7 +475,7 @@
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)
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 @@
CURSORS = [wx.NullCursor,
wx.StockCursor(wx.CURSOR_HAND),
wx.StockCursor(wx.CURSOR_SIZENWSE),
@@ -2321,7 +2321,7 @@
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 @@
"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 @@
segment = len(self.Segments) - 1
# The selected segment is reinitialised
self.StartConnected.SetSelected(False)
@@ -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]
# 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
@@ -2436,7 +2436,7 @@
# Test if a segment have been handled
result = self.TestSegment(pos)
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)
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 @@
# Test if a point has been handled
result = self.TestPoint(pos)
if result == 0 and self.StartConnected is not None:
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 # 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 @@
self.Condition = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2), WEST)
self.Condition = condition
self.RefreshConditionSize()
elif self.Type != "connection":
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:
Function_decl["inputs"] = []
if IsOfType(intype, decl_tpl[1]):
@@ -228,7 +228,7 @@
funcdeclin = funcdeclname
for outype in output_types:
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:
c_type, unpack_func, pack_func = \
TypeTranslator.get(iectype,
--- 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 @@
#print >> self.output, "} else { throw(%s); } " % errName
print >> self.output, "}"
+ if node.else_ is not None: print >>self.output, " } finally {"
self._stmt(stmt, current_klass)
@@ -607,7 +607,7 @@
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 @@
if hasattr(node, "lineno"):
- if node.lineno != None:
+ if node.lineno is not None: srcLine = self.src[min(lineNum, len(self.src))-1]
srcLine = srcLine.replace('\\', '\\\\')
@@ -1445,9 +1445,9 @@
if node.flags == "OP_APPLY":
+ if node.lower is not None: lower = self.expr(node.lower, current_klass)
+ if node.upper is not None: upper = self.expr(node.upper, current_klass)
return "pyjslib.slice(" + self.expr(node.expr, current_klass) + ", " + lower + ", " + upper + ")"
--- 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 @@
# Only update non-existent properties
- if key and result.get(key) == None:
+ if key and result.get(key) is None: --- 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 @@
- "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 is not None: instance.setElementValue(parts[1], value)
--- 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 @@
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: result = CompareSchema(value, ref_value)