# HG changeset patch # User Andrey Skvortsov # Date 1507037491 -10800 # Node ID 14b40afccd69577e96a40fb3ca0dc1d89e4850de # Parent 3abde7651c3848edf94c075fc90846ae4f3c2795 remove unused variables found by pylint diff -r 3abde7651c38 -r 14b40afccd69 BeremizIDE.py --- a/BeremizIDE.py Tue Oct 03 16:12:55 2017 +0300 +++ b/BeremizIDE.py Tue Oct 03 16:31:31 2017 +0300 @@ -559,9 +559,9 @@ result = MATIEC_ERROR_MODEL.match(line) if result is not None: first_line, first_column, last_line, last_column, error = result.groups() - infos = self.CTR.ShowError(self.Log, - (int(first_line), int(first_column)), - (int(last_line), int(last_column))) + self.CTR.ShowError(self.Log, + (int(first_line), int(first_column)), + (int(last_line), int(last_column))) def CheckSaveBeforeClosing(self, title=_("Close Project")): """Function displaying an Error dialog in PLCOpenEditor. @@ -1015,7 +1015,6 @@ def OnProjectTreeItemActivated(self, event): selected = event.GetItem() - name = self.ProjectTree.GetItemText(selected) item_infos = self.ProjectTree.GetPyData(selected) if item_infos["type"] == ITEM_CONFNODE: item_infos["confnode"]._OpenView() @@ -1027,7 +1026,6 @@ def ProjectTreeItemSelect(self, select_item): if select_item is not None and select_item.IsOk(): - name = self.ProjectTree.GetItemText(select_item) item_infos = self.ProjectTree.GetPyData(select_item) if item_infos["type"] == ITEM_CONFNODE: item_infos["confnode"]._OpenView(onlyopened=True) diff -r 3abde7651c38 -r 14b40afccd69 ConfigTreeNode.py --- a/ConfigTreeNode.py Tue Oct 03 16:12:55 2017 +0300 +++ b/ConfigTreeNode.py Tue Oct 03 16:31:31 2017 +0300 @@ -392,10 +392,7 @@ Changes Name to DesiredName if available, Name-N if not. @param DesiredName: The desired Name (string) """ - # Get Current Name - CurrentName = self.BaseParams.getName() - # Do nothing if no change - # if CurrentName == DesiredName: return CurrentName + # Build a list of used Name out of parent's Children AllNames = [] for CTNInstance in self.CTNParent.IterChildren(): diff -r 3abde7651c38 -r 14b40afccd69 IDEFrame.py --- a/IDEFrame.py Tue Oct 03 16:12:55 2017 +0300 +++ b/IDEFrame.py Tue Oct 03 16:31:31 2017 +0300 @@ -374,9 +374,6 @@ kind=wx.ITEM_NORMAL, text=_(u'Undo') + '\tCTRL+Z') AppendMenu(parent, help='', id=wx.ID_REDO, kind=wx.ITEM_NORMAL, text=_(u'Redo') + '\tCTRL+Y') - # AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, - # kind=wx.ITEM_CHECK, text=_(u'Enable Undo/Redo')) - enable_undo_redo = _(u'Enable Undo/Redo') # Keeping text in translations for possible menu reactivation parent.AppendSeparator() AppendMenu(parent, help='', id=wx.ID_CUT, kind=wx.ITEM_NORMAL, text=_(u'Cut') + '\tCTRL+X') @@ -1740,7 +1737,6 @@ def OnProjectTreeItemActivated(self, event): selected = event.GetItem() - name = self.ProjectTree.GetItemText(selected) item_infos = self.ProjectTree.GetPyData(selected) if item_infos["type"] == ITEM_PROJECT: self.EditProjectSettings() @@ -1753,7 +1749,6 @@ def ProjectTreeItemSelect(self, select_item): if select_item is not None and select_item.IsOk(): - name = self.ProjectTree.GetItemText(select_item) item_infos = self.ProjectTree.GetPyData(select_item) if item_infos["type"] in [ITEM_DATATYPE, ITEM_POU, ITEM_CONFIGURATION, ITEM_RESOURCE, @@ -2627,14 +2622,12 @@ # Get the size of the DC in pixels ppiPrinterX, ppiPrinterY = self.GetPPIPrinter() - ppiScreenX, ppiScreenY = self.GetPPIScreen() pw, ph = self.GetPageSizePixels() dw, dh = dc.GetSizeTuple() Xscale = (float(dw) * float(ppiPrinterX)) / (float(pw) * 25.4) Yscale = (float(dh) * float(ppiPrinterY)) / (float(ph) * 25.4) fontsize = self.FontSize * Yscale - text_margin = self.TextMargin * Yscale margin_left = self.Margins[0].x * Xscale margin_top = self.Margins[0].y * Yscale diff -r 3abde7651c38 -r 14b40afccd69 PLCControler.py --- a/PLCControler.py Tue Oct 03 16:12:55 2017 +0300 +++ b/PLCControler.py Tue Oct 03 16:31:31 2017 +0300 @@ -776,7 +776,6 @@ return None def GetPouVariables(self, tagname, debug=False): - pou_type = None project = self.GetProject(debug) if project is not None: factory = VariablesTreeInfosFactory() @@ -1664,7 +1663,6 @@ # Return Block types checking for recursion def GetBlockTypes(self, tagname="", debug=False): - typename = None words = tagname.split("::") name = None project = self.GetProject(debug) diff -r 3abde7651c38 -r 14b40afccd69 PLCGenerator.py --- a/PLCGenerator.py Tue Oct 03 16:12:55 2017 +0300 +++ b/PLCGenerator.py Tue Oct 03 16:31:31 2017 +0300 @@ -394,7 +394,6 @@ resrce += [(" TASK ", ()), (task.getname(), (tagname, "task", task_number, "name")), ("(", ())] - args = [] single = task.getsingle() # Single argument if exists if single is not None: @@ -636,11 +635,6 @@ def ComputeInterface(self, pou): interface = pou.getinterface() if interface is not None: - body = pou.getbody() - if isinstance(body, ListType): - body = body[0] - body_content = body.getcontent() - body_type = body_content.getLocalTag() if self.Type == "FUNCTION": returntype_content = interface.getreturnType()[0] returntype_content_type = returntype_content.getLocalTag() @@ -1024,7 +1018,6 @@ return factorized_paths def GenerateBlock(self, block, block_infos, body, link, order=False, to_inout=False): - body_type = body.getcontent().getLocalTag() name = block.getinstanceName() type = block.gettypeName() executionOrderId = block.getexecutionOrderId() diff -r 3abde7651c38 -r 14b40afccd69 ProjectController.py --- a/ProjectController.py Tue Oct 03 16:12:55 2017 +0300 +++ b/ProjectController.py Tue Oct 03 16:31:31 2017 +0300 @@ -151,7 +151,7 @@ status, result, err_result = ProcessLogger(None, buildcmd, no_stdout=True, no_stderr=True).spin() - except Exception, e: + except Exception: return buildopt for opt in options: @@ -966,7 +966,7 @@ if len(ListGroup) > 2: self._Ticktime = int(ListGroup[2][0]) - except Exception, e: + except Exception: self.logger.write_error(_("Cannot open/parse VARIABLES.csv!\n")) self.logger.write_error(traceback.format_exc()) self.ResetIECProgramsAndVariables() @@ -1107,7 +1107,7 @@ if not builder.build(): self.logger.write_error(_("C Build failed.\n")) return False - except Exception, exc: + except Exception: self.logger.write_error(_("C Build crashed !\n")) self.logger.write_error(traceback.format_exc()) self.ResetBuildMD5() @@ -1126,7 +1126,7 @@ CTNLocationCFilesAndCFLAGS, CTNLDFLAGS, CTNExtraFiles = self._Generate_C( buildpath, self.PLCGeneratedLocatedVars) - except Exception, exc: + except Exception: self.logger.write_error(_("Runtime IO extensions C code generation failed !\n")) self.logger.write_error(traceback.format_exc()) self.ResetBuildMD5() @@ -1135,7 +1135,7 @@ # Generate C code and compilation params from liraries try: LibCFilesAndCFLAGS, LibLDFLAGS, LibExtraFiles = self.GetLibrariesCCode(buildpath) - except Exception, exc: + except Exception: self.logger.write_error(_("Runtime library extensions C code generation failed !\n")) self.logger.write_error(traceback.format_exc()) self.ResetBuildMD5() @@ -1178,7 +1178,7 @@ open(code_path, "w").write(code) # Insert this file as first file to be compiled at root confnode self.LocationCFilesAndCFLAGS[0][1].insert(0, (code_path, self.plcCFLAGS)) - except Exception, exc: + except Exception: self.logger.write_error(name+_(" generation failed !\n")) self.logger.write_error(traceback.format_exc()) self.ResetBuildMD5() @@ -1600,7 +1600,6 @@ # print [dict.keys() for IECPath, (dict, log, status, fvalue) in self.IECdebug_datas.items()] if plc_status == "Started": if len(Traces) > 0: - Failed = False self.IECdebug_lock.acquire() for debug_tick, debug_buff in Traces: debug_vars = UnpackDebugBuffer(debug_buff, self.TracedIECTypes) @@ -1755,7 +1754,7 @@ # Get connector from uri try: self._SetConnector(connectors.ConnectorFactory(uri, self)) - except Exception, msg: + except Exception: self.logger.write_error(_("Exception while connecting %s!\n") % uri) self.logger.write_error(traceback.format_exc()) @@ -1772,13 +1771,6 @@ # Init with actual PLC status and print it self.UpdateMethodsFromPLCStatus() - if self.previous_plcstate is not None: - status = _(self.previous_plcstate) - else: - status = "" - - # self.logger.write(_("PLC is %s\n")%status) - if self.previous_plcstate in ["Started", "Stopped"]: if self.DebugAvailable() and self.GetIECProgramsAndVariables(): self.logger.write(_("Debugger ready\n")) diff -r 3abde7651c38 -r 14b40afccd69 canfestival/canfestival.py --- a/canfestival/canfestival.py Tue Oct 03 16:12:55 2017 +0300 +++ b/canfestival/canfestival.py Tue Oct 03 16:31:31 2017 +0300 @@ -211,7 +211,6 @@ return result def GetVariableLocationTree(self): - current_location = self.GetCurrentLocation() return GetSlaveLocationTree(self.CurrentNode, self.GetCurrentLocation(), self.BaseParams.getName()) diff -r 3abde7651c38 -r 14b40afccd69 connectors/PYRO/__init__.py --- a/connectors/PYRO/__init__.py Tue Oct 03 16:12:55 2017 +0300 +++ b/connectors/PYRO/__init__.py Tue Oct 03 16:31:31 2017 +0300 @@ -97,7 +97,7 @@ confnodesroot.logger.write(_("'{a1}' is located at {a2}\n").format(a1=location, a2=newlocation)) location = newlocation r.close() - except Exception, msg: + except Exception: confnodesroot.logger.write_error(_("MDNS resolution failure for '%s'\n") % location) confnodesroot.logger.write_error(traceback.format_exc()) return None @@ -105,7 +105,7 @@ # Try to get the proxy object try: RemotePLCObjectProxy = Pyro.core.getAttrProxyForURI(schemename + "://" + location + "/PLCObject") - except Exception, msg: + except Exception: confnodesroot.logger.write_error(_("Connection to '%s' failed.\n") % location) confnodesroot.logger.write_error(traceback.format_exc()) return None diff -r 3abde7651c38 -r 14b40afccd69 connectors/WAMP/__init__.py --- a/connectors/WAMP/__init__.py Tue Oct 03 16:12:55 2017 +0300 +++ b/connectors/WAMP/__init__.py Tue Oct 03 16:31:31 2017 +0300 @@ -118,10 +118,10 @@ return threads.blockingCallFromThread( reactor, _WampSession.call, wampfuncname, *args, **kwargs) - except TransportLost, e: + except TransportLost: confnodesroot.logger.write_error(_("Connection lost!\n")) confnodesroot._SetConnector(None) - except Exception, e: + except Exception: errmess = traceback.format_exc() confnodesroot.logger.write_error(errmess+"\n") print(errmess) @@ -156,7 +156,7 @@ # Try to get the proxy object try: return WampPLCObjectProxy() - except Exception, msg: + except Exception: confnodesroot.logger.write_error(_("WAMP connection to '%s' failed.\n") % location) confnodesroot.logger.write_error(traceback.format_exc()) return None diff -r 3abde7651c38 -r 14b40afccd69 controls/DebugVariablePanel/DebugVariablePanel.py --- a/controls/DebugVariablePanel/DebugVariablePanel.py Tue Oct 03 16:12:55 2017 +0300 +++ b/controls/DebugVariablePanel/DebugVariablePanel.py Tue Oct 03 16:31:31 2017 +0300 @@ -657,7 +657,7 @@ def OnRangeChanged(self, event): try: self.CurrentRange = RANGE_VALUES[self.CanvasRange.GetSelection()][1] / self.Ticktime - except ValueError, e: + except ValueError: self.CanvasRange.SetValue(str(self.CurrentRange)) wx.CallAfter(self.RefreshRange) event.Skip() diff -r 3abde7651c38 -r 14b40afccd69 controls/EnhancedStatusBar.py --- a/controls/EnhancedStatusBar.py Tue Oct 03 16:12:55 2017 +0300 +++ b/controls/EnhancedStatusBar.py Tue Oct 03 16:31:31 2017 +0300 @@ -111,7 +111,6 @@ widget, horizontalalignment, verticalalignment = item.widget, item.horizontalalignment, item.verticalalignment rect = self.GetFieldRect(pos) - widgetpos = widget.GetPosition() widgetsize = widget.GetSize() rect = self.GetFieldRect(pos) diff -r 3abde7651c38 -r 14b40afccd69 controls/LogViewer.py --- a/controls/LogViewer.py Tue Oct 03 16:12:55 2017 +0300 +++ b/controls/LogViewer.py Tue Oct 03 16:31:31 2017 +0300 @@ -119,7 +119,6 @@ def OnMotion(self, event): if event.Dragging() and self.ThumbScrollingStartPos is not None: posx, posy = event.GetPosition() - width, height = self.GetClientSize() range_rect = self.GetRangeRect() thumb_size = range_rect.height * THUMB_SIZE_RATIO thumb_range = range_rect.height - thumb_size diff -r 3abde7651c38 -r 14b40afccd69 controls/PouInstanceVariablesPanel.py --- a/controls/PouInstanceVariablesPanel.py Tue Oct 03 16:12:55 2017 +0300 +++ b/controls/PouInstanceVariablesPanel.py Tue Oct 03 16:31:31 2017 +0300 @@ -113,8 +113,6 @@ dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.SetPen(wx.TRANSPARENT_PEN) - bg_width = (r_image_w + 4) * len(rightimages) + 4 - bg_height = r_image_h + 8 dc.DrawRectangle(images_bbx.x, images_bbx.y, images_bbx.width, images_bbx.height) x_pos = images_bbx.x + 4 diff -r 3abde7651c38 -r 14b40afccd69 controls/SearchResultPanel.py --- a/controls/SearchResultPanel.py Tue Oct 03 16:12:55 2017 +0300 +++ b/controls/SearchResultPanel.py Tue Oct 03 16:31:31 2017 +0300 @@ -272,7 +272,6 @@ return OnTextCtrlDClick def GenerateSearchResultsTreeBranch(self, root, infos): - to_delete = [] if infos["name"] == "body": item_name = "%d:" % infos["data"][1][0] else: diff -r 3abde7651c38 -r 14b40afccd69 controls/VariablePanel.py --- a/controls/VariablePanel.py Tue Oct 03 16:12:55 2017 +0300 +++ b/controls/VariablePanel.py Tue Oct 03 16:31:31 2017 +0300 @@ -663,7 +663,6 @@ def _RefreshButtons(): if self: table_length = len(self.Table.data) - row_class = None row_edit = True row = 0 if table_length > 0: diff -r 3abde7651c38 -r 14b40afccd69 dialogs/DurationEditorDialog.py --- a/dialogs/DurationEditorDialog.py Tue Oct 03 16:12:55 2017 +0300 +++ b/dialogs/DurationEditorDialog.py Tue Oct 03 16:31:31 2017 +0300 @@ -117,8 +117,8 @@ def GetControlValueTestFunction(self, control): def OnValueChanged(event): try: - value = float(control.GetValue()) - except ValueError, e: + float(control.GetValue()) + except ValueError: message = wx.MessageDialog(self, _("Invalid value!\nYou must fill a numeric value."), _("Error"), wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy() @@ -157,8 +157,8 @@ (self.Minutes, _("minutes")), (self.Seconds, _("seconds")), (self.Milliseconds, _("milliseconds"))]: try: - value = float(control.GetValue()) - except ValueError, e: + float(control.GetValue()) + except ValueError: errors.append(name) if len(errors) > 0: if len(errors) == 1: diff -r 3abde7651c38 -r 14b40afccd69 dialogs/ForceVariableDialog.py --- a/dialogs/ForceVariableDialog.py Tue Oct 03 16:12:55 2017 +0300 +++ b/dialogs/ForceVariableDialog.py Tue Oct 03 16:31:31 2017 +0300 @@ -103,7 +103,7 @@ year, month, day = result.groups() try: date = datetime.datetime(int(year), int(month), int(day)) - except ValueError, e: + except ValueError: return None base_date = datetime.datetime(1970, 1, 1) return date - base_date @@ -117,7 +117,7 @@ year, month, day, hours, minutes, seconds = result.groups() try: date = datetime.datetime(int(year), int(month), int(day), int(hours), int(minutes), int(float(seconds)), int((float(seconds) * SECOND) % SECOND)) - except ValueError, e: + except ValueError: return None base_date = datetime.datetime(1970, 1, 1) return date - base_date diff -r 3abde7651c38 -r 14b40afccd69 editors/CodeFileEditor.py --- a/editors/CodeFileEditor.py Tue Oct 03 16:12:55 2017 +0300 +++ b/editors/CodeFileEditor.py Tue Oct 03 16:31:31 2017 +0300 @@ -200,7 +200,6 @@ except Exception: values = event.GetDragText() if isinstance(values, tuple): - message = None if values[3] == self.Controler.GetCurrentLocation(): self.ResetBuffer() event.SetDragText(values[0]) @@ -339,8 +338,6 @@ return elif key == 32 and event.ControlDown(): - pos = self.GetCurrentPos() - # Tips if event.ShiftDown(): pass @@ -619,8 +616,6 @@ Otherwise default to the default renderer. """ - typelist = None - accesslist = None for row in range(self.GetNumberRows()): for col in range(self.GetNumberCols()): editor = None diff -r 3abde7651c38 -r 14b40afccd69 editors/ConfTreeNodeEditor.py --- a/editors/ConfTreeNodeEditor.py Tue Oct 03 16:12:55 2017 +0300 +++ b/editors/ConfTreeNodeEditor.py Tue Oct 03 16:31:31 2017 +0300 @@ -496,7 +496,7 @@ def GetItemChannelChangedFunction(self, dir): def OnConfNodeTreeItemChannelChanged(event): confnode_IECChannel = self.Controler.BaseParams.getIEC_Channel() - res = self.SetConfNodeParamsAttribute("BaseParams.IEC_Channel", confnode_IECChannel + dir) + self.SetConfNodeParamsAttribute("BaseParams.IEC_Channel", confnode_IECChannel + dir) wx.CallAfter(self.RefreshIECChannelControlsState) wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE) event.Skip() @@ -534,7 +534,7 @@ def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, path): def OnChoiceContentChanged(event): - res = self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection()) + self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection()) wx.CallAfter(self.RefreshConfNodeParamsSizer) event.Skip() return OnChoiceContentChanged diff -r 3abde7651c38 -r 14b40afccd69 editors/Viewer.py --- a/editors/Viewer.py Tue Oct 03 16:12:55 2017 +0300 +++ b/editors/Viewer.py Tue Oct 03 16:31:31 2017 +0300 @@ -279,7 +279,6 @@ elif values[1] == "program": message = _("Programs can't be used by other POUs!") elif values[1] in ["function", "functionBlock"]: - words = tagname.split("::") if pou_name == values[0]: message = _("\"%s\" can't use itself!") % pou_name elif pou_type == "function" and values[1] != "function": @@ -1244,7 +1243,7 @@ self.Flush() self.ResetView() self.ResetBuffer() - instance = {} + # List of ids of already loaded blocks instances = self.Controler.GetEditedElementInstancesInfos(self.TagName, debug=self.Debug) # Load Blocks until they are all loaded @@ -1841,7 +1840,6 @@ # Calculate position of connector at the right of start connector connector = connection.GetConnectors()["inputs"][0] rel_pos = connector.GetRelPosition() - direction = connector.GetDirection() start_point = start_connector.GetPosition(False) end_point = (start_point[0] + LD_WIRE_SIZE, start_point[1]) connection.SetPosition(end_point[0] - rel_pos[0], @@ -1874,7 +1872,6 @@ # Calculate position of connection at the left of end connector connector = connection.GetConnectors()["outputs"][0] rel_pos = connector.GetRelPosition() - direction = connector.GetDirection() end_point = end_connector.GetPosition(False) start_point = (end_point[0] - LD_WIRE_SIZE, end_point[1]) connection.SetPosition(start_point[0] - rel_pos[0], @@ -2314,7 +2311,6 @@ def OnViewerMotion(self, event): if self.Editor.HasCapture() and not event.Dragging(): return - refresh = False dc = self.GetLogicalDC() pos = GetScaledEventPosition(event, dc, self.Scaling) if event.MiddleIsDown() or self.Mode == MODE_MOTION: @@ -3682,7 +3678,6 @@ self.RefreshVisibleElements(xp=xp) self.Scroll(xp, y) elif event.ControlDown(): - dc = self.GetLogicalDC() self.SetScale(self.CurrentScale + rotation, mouse_event=event) self.ParentWindow.RefreshDisplayMenu() else: diff -r 3abde7651c38 -r 14b40afccd69 graphics/GraphicCommons.py --- a/graphics/GraphicCommons.py Tue Oct 03 16:12:55 2017 +0300 +++ b/graphics/GraphicCommons.py Tue Oct 03 16:31:31 2017 +0300 @@ -472,7 +472,6 @@ # Method called when a LeftDown event have been generated def OnLeftDown(self, event, dc, scaling): - pos = event.GetLogicalPosition(dc) # Test if an handle have been clicked handle = self.TestHandle(event) # Find which type of handle have been clicked, @@ -1412,8 +1411,6 @@ dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR)) dc.SetLogicalFunction(wx.AND) parent_pos = self.ParentBlock.GetPosition() - posx = parent_pos[0] + self.Pos.x - posy = parent_pos[1] + self.Pos.y xstart = parent_pos[0] + self.Pos.x ystart = parent_pos[1] + self.Pos.y if self.Direction[0] < 0: @@ -2627,7 +2624,6 @@ self.Refresh() def HighlightPoint(self, pos): - refresh = False start, end = self.OverStart, self.OverEnd self.OverStart = False self.OverEnd = False diff -r 3abde7651c38 -r 14b40afccd69 graphics/SFC_Objects.py --- a/graphics/SFC_Objects.py Tue Oct 03 16:12:55 2017 +0300 +++ b/graphics/SFC_Objects.py Tue Oct 03 16:31:31 2017 +0300 @@ -460,7 +460,6 @@ if scaling is not None: movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x movey = round(float(self.Pos.y + movey) / float(scaling[1])) * scaling[1] - self.Pos.y - action_block = None if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: self.Move(movex, movey) self.RefreshConnected() @@ -857,7 +856,6 @@ # Align input element with this step def RefreshInputPosition(self): - wires = self.Input.GetWires() current_pos = self.Input.GetPosition(False) input = self.GetPreviousConnector() if input: @@ -1351,10 +1349,7 @@ wires = output_connector.GetWires() if len(wires) != 1: return - current_pos = output_connector.GetPosition(False) output = wires[0][0].GetOtherConnected(self.Output) - output_pos = output.GetPosition(False) - diffx = current_pos.x - output_pos.x output_block = output.GetParentBlock() if isinstance(output_block, SFC_Step): output_block.MoveActionBlock(move) diff -r 3abde7651c38 -r 14b40afccd69 plcopen/plcopen.py --- a/plcopen/plcopen.py Tue Oct 03 16:12:55 2017 +0300 +++ b/plcopen/plcopen.py Tue Oct 03 16:31:31 2017 +0300 @@ -1061,7 +1061,6 @@ def Search(self, criteria, parent_infos=[]): search_result = [] - filter = criteria["filter"] for datatype in self.dataTypes.getdataType(): search_result.extend(datatype.Search(criteria, parent_infos)) for pou in self.pous.getpou(): @@ -1113,7 +1112,7 @@ self.content.updateElementName(old_name, new_name) elif content_name == "struct": for element in self.content.getvariable(): - element_type = element.type.updateElementName(old_name, new_name) + element.type.updateElementName(old_name, new_name) setattr(cls, "updateElementName", updateElementName) def Search(self, criteria, parent_infos=[]): diff -r 3abde7651c38 -r 14b40afccd69 plcopen/structures.py --- a/plcopen/structures.py Tue Oct 03 16:12:55 2017 +0300 +++ b/plcopen/structures.py Tue Oct 03 16:31:31 2017 +0300 @@ -193,7 +193,6 @@ section_name = fields[0] Current_section = {"name": section_name, "list": []} Standard_Functions_Decl.append(Current_section) - Function_decl_list = [] if Current_section: Function_decl = dict([(champ, val) for champ, val in zip(fonctions, fields[1:]) if champ]) baseinputnumber = int(Function_decl.get("baseinputnumber", 1)) diff -r 3abde7651c38 -r 14b40afccd69 py_ext/PythonFileCTNMixin.py --- a/py_ext/PythonFileCTNMixin.py Tue Oct 03 16:12:55 2017 +0300 +++ b/py_ext/PythonFileCTNMixin.py Tue Oct 03 16:31:31 2017 +0300 @@ -146,6 +146,13 @@ globalsection = self.GetSection("globals") + loc_dict = { + "pyextname": pyextname, + "globalstubs": globalstubs, + "globalsection": globalsection, + "rtcalls": rtcalls, + } + PyFileContent = """\ #!/usr/bin/env python # -*- coding: utf-8 -*- @@ -168,7 +175,7 @@ del __ext_name__ -""" % locals() +""" % loc_dict # write generated content to python file runtimefile_path = os.path.join(buildpath, @@ -246,6 +253,14 @@ onchangelen=len(varinfo["onchangecode"]), **varinfo) for varinfo in varinfos if varinfo["onchange"]]) + loc_dict = { + "vardec": vardec, + "varinit": varinit, + "varret": varret, + "varpub": varpub, + "location_str": location_str, + } + # TODO : use config name obtained from model instead of default # "config.h". User cannot change config name, but project imported # or created in older beremiz vesion could use different name. @@ -278,7 +293,7 @@ void __publish_%(location_str)s(void){ %(varpub)s } -""" % locals() +""" % loc_dict Gen_PyCfile_path = os.path.join(buildpath, "PyCFile_%s.c" % location_str) pycfile = open(Gen_PyCfile_path, 'w') diff -r 3abde7651c38 -r 14b40afccd69 runtime/NevowServer.py --- a/runtime/NevowServer.py Tue Oct 03 16:12:55 2017 +0300 +++ b/runtime/NevowServer.py Tue Oct 03 16:31:31 2017 +0300 @@ -185,7 +185,6 @@ website = WebInterface() site = appserver.NevowSite(website) - listening = False reactor.listenTCP(port, site) print(_('HTTP interface port :'), port) return website diff -r 3abde7651c38 -r 14b40afccd69 runtime/PLCObject.py --- a/runtime/PLCObject.py Tue Oct 03 16:12:55 2017 +0300 +++ b/runtime/PLCObject.py Tue Oct 03 16:31:31 2017 +0300 @@ -91,7 +91,7 @@ "r").read().strip() + lib_ext if self.LoadPLC(): self.PLCStatus = "Stopped" - except Exception, e: + except Exception: self.PLCStatus = "Empty" self.CurrentPLCFilename = None @@ -287,7 +287,7 @@ except KeyError: raise KeyError("Try to get unknown shared global variable : %s" % name) v = t() - r = self.python_runtime_vars["_PySafeGetPLCGlob_"+name](ctypes.byref(v)) + self.python_runtime_vars["_PySafeGetPLCGlob_"+name](ctypes.byref(v)) return self.python_runtime_vars["_"+name+"_unpack"](v) def __setattr__(_self, name, value): @@ -363,7 +363,6 @@ def StartPLC(self): if self.CurrentPLCFilename is not None and self.PLCStatus == "Stopped": c_argv = ctypes.c_char_p * len(self.argv) - error = None res = self._startPLC(len(self.argv), c_argv(*self.argv)) if res == 0: self.PLCStatus = "Started" diff -r 3abde7651c38 -r 14b40afccd69 runtime/ServicePublisher.py --- a/runtime/ServicePublisher.py Tue Oct 03 16:12:55 2017 +0300 +++ b/runtime/ServicePublisher.py Tue Oct 03 16:31:31 2017 +0300 @@ -45,7 +45,7 @@ def RegisterService(self, name, ip, port): try: self._RegisterService(name, ip, port) - except Exception, e: + except Exception: self.retrytimer = threading.Timer(2, self.RegisterService, [name, ip, port]) self.retrytimer.start() @@ -93,6 +93,6 @@ s.close() if host != '0.0.0.0': return host - except Exception, e: + except Exception: pass return socket.gethostbyname(socket.gethostname()) diff -r 3abde7651c38 -r 14b40afccd69 runtime/WampClient.py --- a/runtime/WampClient.py Tue Oct 03 16:12:55 2017 +0300 +++ b/runtime/WampClient.py Tue Oct 03 16:31:31 2017 +0300 @@ -73,10 +73,10 @@ ID = self.config.extra["ID"] print('WAMP session joined by :', ID) for name in ExposedCalls: - reg = yield self.register(GetCallee(name), '.'.join((ID, name))) + yield self.register(GetCallee(name), '.'.join((ID, name))) for name in SubscribedEvents: - reg = yield self.subscribe(GetCallee(name), name) + yield self.subscribe(GetCallee(name), name) for func in DoOnJoin: yield func(self) diff -r 3abde7651c38 -r 14b40afccd69 svgui/pyjs/build.py --- a/svgui/pyjs/build.py Tue Oct 03 16:12:55 2017 +0300 +++ b/svgui/pyjs/build.py Tue Oct 03 16:31:31 2017 +0300 @@ -284,7 +284,6 @@ os.unlink(p) app_files = [] - tmpl = read_boilerplate(data_dir, "all.cache.html") parser = pyjs.PlatformParser("platform") app_headers = '' scripts = ['' % diff -r 3abde7651c38 -r 14b40afccd69 svgui/pyjs/pyjs.py --- a/svgui/pyjs/pyjs.py Tue Oct 03 16:12:55 2017 +0300 +++ b/svgui/pyjs/pyjs.py Tue Oct 03 16:31:31 2017 +0300 @@ -398,15 +398,15 @@ default_pos -= 1 self.printo(function_name+'.parse_kwargs = function (', ", ".join(["__kwargs"]+arg_names), ") {") for default_node in node.defaults: - default_value = self.expr(default_node, current_klass) -# if isinstance(default_node, ast.Const): -# default_value = self._const(default_node) -# elif isinstance(default_node, ast.Name): -# default_value = self._name(default_node) -# elif isinstance(default_node, ast.UnarySub): -# default_value = self._unarysub(default_node, current_klass) -# else: -# raise TranslationError("unsupported type (in _method)", default_node) + # default_value = self.expr(default_node, current_klass) + # if isinstance(default_node, ast.Const): + # default_value = self._const(default_node) + # elif isinstance(default_node, ast.Name): + # default_value = self._name(default_node) + # elif isinstance(default_node, ast.UnarySub): + # default_value = self._unarysub(default_node, current_klass) + # else: + # raise TranslationError("unsupported type (in _method)", default_node) default_name = arg_names[default_pos] self.printo(" if (typeof %s == 'undefined')" % (default_name)) @@ -1011,8 +1011,6 @@ if debugStmt: lt = self.get_line_trace(node) - - haltException = self.module_prefix + "HaltException" isHaltFunction = self.module_prefix + "IsHaltException" out = ( @@ -1077,7 +1075,6 @@ def _lhsFromAttr(v, current_klass): attr_name = v.attrname if isinstance(v.expr, ast.Name): - obj = v.expr.name lhs = self._name(v.expr, current_klass) + "." + attr_name elif isinstance(v.expr, ast.Getattr): lhs = self._getattr(v, current_klass) @@ -1318,13 +1315,21 @@ lhs = "var " + assign_name iterator_name = "__" + assign_name + loc_dict = { + "iterator_name": iterator_name, + "list_expr": list_expr, + "lhs": lhs, + "op": op, + "assign_tuple": assign_tuple, + } + self.printo(""" var %(iterator_name)s = %(list_expr)s.__iter__(); try { while (true) { %(lhs)s %(op)s %(iterator_name)s.next(); %(assign_tuple)s - """ % locals()) + """ % loc_dict) for node in node.body.nodes: self._stmt(node, current_klass) self.printo(""" @@ -1334,7 +1339,7 @@ throw e; } } - """ % locals()) + """) def _while(self, node, current_klass): test = self.expr(node.test, current_klass) @@ -1530,7 +1535,7 @@ f.close() output = cStringIO.StringIO() mod = compiler.parseFile(file_name) - t = Translator(module_name, module_name, module_name, src, debug, mod, output) + Translator(module_name, module_name, module_name, src, debug, mod, output) return output.getvalue() diff -r 3abde7651c38 -r 14b40afccd69 targets/toolchain_gcc.py --- a/targets/toolchain_gcc.py Tue Oct 03 16:12:55 2017 +0300 +++ b/targets/toolchain_gcc.py Tue Oct 03 16:31:31 2017 +0300 @@ -73,7 +73,7 @@ def GetBinaryCode(self): try: return open(self.exe_path, "rb").read() - except Exception, e: + except Exception: return None def _GetMD5FileName(self): @@ -83,7 +83,7 @@ self.md5key = None try: os.remove(self._GetMD5FileName()) - except Exception, e: + except Exception: pass def GetBinaryCodeMD5(self): @@ -92,7 +92,7 @@ else: try: return open(self._GetMD5FileName(), "r").read() - except Exception, e: + except Exception: return None def SetBuildPath(self, buildpath): @@ -206,8 +206,6 @@ # Link all the object files into one binary file self.CTRInstance.logger.write(_("Linking :\n")) if relink: - objstring = [] - # Generate list .o files listobjstring = '"' + '" "'.join(objs) + '"' diff -r 3abde7651c38 -r 14b40afccd69 targets/toolchain_makefile.py --- a/targets/toolchain_makefile.py Tue Oct 03 16:12:55 2017 +0300 +++ b/targets/toolchain_makefile.py Tue Oct 03 16:31:31 2017 +0300 @@ -56,7 +56,7 @@ self.md5key = None try: os.remove(self._GetMD5FileName()) - except Exception, e: + except Exception: pass def GetBinaryCodeMD5(self): @@ -65,7 +65,7 @@ else: try: return open(self._GetMD5FileName(), "r").read() - except IOError, e: + except IOError: return None def concat_deps(self, bn): diff -r 3abde7651c38 -r 14b40afccd69 tests/tools/check_source.sh --- a/tests/tools/check_source.sh Tue Oct 03 16:12:55 2017 +0300 +++ b/tests/tools/check_source.sh Tue Oct 03 16:31:31 2017 +0300 @@ -200,6 +200,7 @@ disable=$disable,C0302 # Too many lines in module disable=$disable,W0511 # fixme disable=$disable,W0110 # (deprecated-lambda) map/filter on lambda could be replaced by comprehension + disable=$disable,W1401 # (anomalous-backslash-in-string) Anomalous backslash in string: '\.'. String constant might be missing an r prefix. enable= enable=$enable,E1601 # print statement used @@ -215,6 +216,7 @@ enable=$enable,W0101 # (unreachable) Unreachable code enable=$enable,E0102 # (function-redefined) method already defined enable=$enable,W0602 # (global-variable-not-assigned) Using global for 'X' but no assignment is done + enable=$enable,W0612 # (unused-variable) Unused variable 'X' # enable=$enable,W0403 # relative import # enable=$enable,W0622 # (redefined-builtin) Redefining built-in diff -r 3abde7651c38 -r 14b40afccd69 version.py --- a/version.py Tue Oct 03 16:12:55 2017 +0300 +++ b/version.py Tue Oct 03 16:31:31 2017 +0300 @@ -111,7 +111,6 @@ # read license file path = paths.AbsDir(__file__) license_path = os.path.join(path, "COPYING") - license = '' if os.path.exists(license_path): with open(license_path) as f: info.License += f.read() diff -r 3abde7651c38 -r 14b40afccd69 xmlclass/xmlclass.py --- a/xmlclass/xmlclass.py Tue Oct 03 16:12:55 2017 +0300 +++ b/xmlclass/xmlclass.py Tue Oct 03 16:31:31 2017 +0300 @@ -722,7 +722,6 @@ def ExtractElement(factory, node): attrs = factory.ExtractNodeAttrs(element_name, node, attributes) children_structure = "" - children_infos = [] children = [] for child in node.childNodes: if child.nodeName not in ["#comment", "#text"]: @@ -1278,7 +1277,6 @@ def generateGetattrMethod(factory, class_definition, classinfos): attributes = dict([(attr["name"], attr) for attr in classinfos["attributes"] if attr["use"] != "prohibited"]) - optional_attributes = dict([(attr["name"], True) for attr in classinfos["attributes"] if attr["use"] == "optional"]) elements = dict([(element["name"], element) for element in classinfos["elements"]]) def getattrMethod(self, name): @@ -1579,10 +1577,6 @@ self.set(attribute["name"], attribute["attr_type"]["generate"](attribute["attr_type"]["initial"]())) for element in classinfos["elements"]: if element["type"] != CHOICE: - element_name = ( - etree.QName(factory.NSMAP["xhtml"], "p") - if element["type"] == ANY - else factory.etreeNamespaceFormat % element["name"]) initial = GetElementInitialValue(factory, element) if initial is not None: map(self.append, initial) diff -r 3abde7651c38 -r 14b40afccd69 xmlclass/xsdschema.py --- a/xmlclass/xsdschema.py Tue Oct 03 16:12:55 2017 +0300 +++ b/xmlclass/xsdschema.py Tue Oct 03 16:31:31 2017 +0300 @@ -459,10 +459,6 @@ # Generate extract value for new created type def ExtractSimpleTypeValue(attr, extract=True): - if extract: - value = GetAttributeValue(attr) - else: - value = attr for infos in membertypesinfos: try: return infos["extract"](attr, False)