# HG changeset patch # User Andrey Skvortsov # Date 1502788671 -10800 # Node ID ec153828ded239fef97936c9e18ec6b4ef6e0daa # Parent d2e97973870077c447d528f0c3cf8946449f2283 clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ',' diff -r d2e979738700 -r ec153828ded2 Beremiz.py --- a/Beremiz.py Mon Aug 14 23:38:28 2017 +0300 +++ b/Beremiz.py Tue Aug 15 12:17:51 2017 +0300 @@ -111,7 +111,7 @@ def CreateApplication(self): if os.path.exists("BEREMIZ_DEBUG"): __builtin__.__dict__["BMZ_DBG"] = True - else : + else: __builtin__.__dict__["BMZ_DBG"] = False global wxversion, wx @@ -160,10 +160,10 @@ def updateinfoproc(): global updateinfo - try : + try: import urllib2 updateinfo = urllib2.urlopen(self.updateinfo_url,None).read() - except : + except: updateinfo = _("update info unavailable.") from threading import Thread diff -r d2e979738700 -r ec153828ded2 BeremizIDE.py --- a/BeremizIDE.py Mon Aug 14 23:38:28 2017 +0300 +++ b/BeremizIDE.py Tue Aug 15 12:17:51 2017 +0300 @@ -76,13 +76,13 @@ if wx.Platform == '__WXMSW__': faces = { - 'mono' : 'Courier New', - 'size' : 8, + 'mono': 'Courier New', + 'size': 8, } else: faces = { - 'mono' : 'Courier', - 'size' : 10, + 'mono': 'Courier', + 'size': 10, } from threading import Lock,Timer,currentThread @@ -146,11 +146,11 @@ self.YieldLock.release() def _write(self): - if self.output : + if self.output: self.output.Freeze() self.lock.acquire() for s, style in self.stack: - if style is None : style=self.black_white + if style is None: style=self.black_white if style != self.black_white: self.output.StartStyling(self.output.GetLength(), 0xff) @@ -487,7 +487,7 @@ sys.executable, Bpath("Beremiz_service.py"), self.runtime_port, - {False : "-x 0", True :"-x 1"}[taskbaricon], + {False: "-x 0", True:"-x 1"}[taskbaricon], self.local_runtime_tmpdir), no_gui=False, timeout=500, keyword = self.local_runtime_tmpdir, @@ -613,7 +613,7 @@ self.SaveLastState() - for Thing in self.ToDoBeforeQuit : + for Thing in self.ToDoBeforeQuit: Thing() self.ToDoBeforeQuit = [] @@ -844,7 +844,7 @@ except: defaultpath = os.path.expanduser("~") - dialog = wx.DirDialog(self , _("Choose an empty directory for new project"), defaultpath) + dialog = wx.DirDialog(self, _("Choose an empty directory for new project"), defaultpath) if dialog.ShowModal() == wx.ID_OK: projectpath = dialog.GetPath() self.Config.Write("lastopenedfolder", @@ -880,7 +880,7 @@ except: defaultpath = os.path.expanduser("~") - dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, style=wx.DEFAULT_DIALOG_STYLE| + dialog = wx.DirDialog(self, _("Choose a project"), defaultpath, style=wx.DEFAULT_DIALOG_STYLE| wx.RESIZE_BORDER) if dialog.ShowModal() == wx.ID_OK: self.OpenProject(dialog.GetPath()) diff -r d2e979738700 -r ec153828ded2 Beremiz_service.py --- a/Beremiz_service.py Mon Aug 14 23:38:28 2017 +0300 +++ b/Beremiz_service.py Tue Aug 15 12:17:51 2017 +0300 @@ -212,7 +212,7 @@ def OnOK(self, event): value = self.GetValue() - texts = {"value" : value} + texts = {"value": value} for function, message in self.Tests: if not function(value): message = wx.MessageDialog(self, message % texts, _("Error"), wx.OK|wx.ICON_ERROR) @@ -313,7 +313,7 @@ ip_addr = '' if ip_addr is None else ip_addr dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=ip_addr) dlg.SetTests([(re.compile('\d{1,3}(?:\.\d{1,3}){3}$').match, _("IP is not valid!")), - ( lambda x :len([x for x in x.split(".") if 0 <= int(x) <= 255]) == 4, _("IP is not valid!")) + ( lambda x:len([x for x in x.split(".") if 0 <= int(x) <= 255]) == 4, _("IP is not valid!")) ]) if dlg.ShowModal() == wx.ID_OK: self.pyroserver.ip_addr = dlg.GetValue() @@ -321,7 +321,7 @@ def OnTaskBarChangePort(self, evt): dlg = ParamsEntryDialog(None, _("Enter a port number "), defaultValue=str(self.pyroserver.port)) - dlg.SetTests([(UnicodeType.isdigit, _("Port number must be an integer!")), (lambda port : 0 <= int(port) <= 65535 , _("Port number must be 0 <= port <= 65535!"))]) + dlg.SetTests([(UnicodeType.isdigit, _("Port number must be an integer!")), (lambda port: 0 <= int(port) <= 65535, _("Port number must be 0 <= port <= 65535!"))]) if dlg.ShowModal() == wx.ID_OK: self.pyroserver.port = int(dlg.GetValue()) self.pyroserver.Stop() @@ -336,7 +336,7 @@ servicename = self.pyroserver.servicename servicename = '' if servicename is None else servicename dlg = ParamsEntryDialog(None, _("Enter a name "), defaultValue=servicename) - dlg.SetTests([(lambda name : len(name) is not 0 , _("Name must not be null!"))]) + dlg.SetTests([(lambda name: len(name) is not 0, _("Name must not be null!"))]) if dlg.ShowModal() == wx.ID_OK: self.pyroserver.servicename = dlg.GetValue() self.pyroserver.Restart() @@ -368,7 +368,7 @@ wx.CallAfter(wx.GetApp().ExitMainLoop) def UpdateIcon(self, plcstatus): - if plcstatus is "Started" : + if plcstatus is "Started": currenticon = self.MakeIcon(starticon) elif plcstatus is "Stopped": currenticon = self.MakeIcon(stopicon) @@ -452,7 +452,7 @@ self.plcobj.AutoLoad() if self.plcobj.GetPLCstatus()[0] != "Empty": - if self.autostart : + if self.autostart: self.plcobj.StartPLC() self.plcobj.StatusChange() @@ -561,7 +561,7 @@ installThreadExcepthook() if havetwisted: - if webport is not None : + if webport is not None: try: import runtime.NevowServer as NS except Exception, e: @@ -569,7 +569,7 @@ webport = None NS.WorkingDir = WorkingDir - if wampconf is not None : + if wampconf is not None: try: import runtime.WampClient as WC except Exception, e: @@ -583,7 +583,7 @@ execfile(extfilename, locals()) if havetwisted: - if webport is not None : + if webport is not None: try: website = NS.RegisterWebsite(webport) pyruntimevars["website"] = website @@ -591,7 +591,7 @@ except Exception, e: print _("Nevow Web service failed. "), e - if wampconf is not None : + if wampconf is not None: try: WC.RegisterWampClient(wampconf) pyruntimevars["wampsession"] = WC.GetSession @@ -609,7 +609,7 @@ elif havewx: app.MainLoop() else: - try : + try: pyroserver.Loop() except KeyboardInterrupt,e: pass diff -r d2e979738700 -r ec153828ded2 CodeFileTreeNode.py --- a/CodeFileTreeNode.py Mon Aug 14 23:38:28 2017 +0300 +++ b/CodeFileTreeNode.py Tue Aug 15 12:17:51 2017 +0300 @@ -159,12 +159,12 @@ def GetVariables(self): datas = [] for var in self.CodeFileVariables(self.CodeFile): - datas.append({"Name" : var.getname(), - "Type" : var.gettype(), - "Initial" : var.getinitial(), - "Description" : var.getdesc(), - "OnChange" : var.getonchange(), - "Options" : var.getopts(), + datas.append({"Name": var.getname(), + "Type": var.gettype(), + "Initial": var.getinitial(), + "Description": var.getdesc(), + "OnChange": var.getonchange(), + "Options": var.getopts(), }) return datas diff -r d2e979738700 -r ec153828ded2 ConfigTreeNode.py --- a/ConfigTreeNode.py Mon Aug 14 23:38:28 2017 +0300 +++ b/ConfigTreeNode.py Tue Aug 15 12:17:51 2017 +0300 @@ -453,10 +453,10 @@ while res in AllChannels: # While channel not free if res < CurrentChannel: # Want to go down ? res -= 1 # Test for n-1 - if res < 0 : + if res < 0: self.GetCTRoot().logger.write_warning(_("Cannot find lower free IEC channel than %d\n") % CurrentChannel) return CurrentChannel # Can't go bellow 0, do nothing - else : # Want to go up ? + else: # Want to go up ? res += 1 # Test for n-1 # Finally set IEC Channel self.BaseParams.setIEC_Channel(res) diff -r d2e979738700 -r ec153828ded2 IDEFrame.py --- a/IDEFrame.py Mon Aug 14 23:38:28 2017 +0300 +++ b/IDEFrame.py Tue Aug 15 12:17:51 2017 +0300 @@ -96,95 +96,95 @@ # - Item icon filename # - Item tooltip text EditorToolBarItems = { - "FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", - "move", _("Move the view")), - (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", - "add_comment", _("Create a new comment")), - (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", - "add_variable", _("Create a new variable")), - (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", - "add_block", _("Create a new block")), - (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", - "add_connection", _("Create a new connection"))], - "LD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", - "move", _("Move the view")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", - "add_comment", _("Create a new comment")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", - "add_powerrail", _("Create a new power rail")), - (False, DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool", - "add_rung", _("Create a new rung")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool", - "add_coil", _("Create a new coil")), - (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", - "add_contact", _("Create a new contact")), - (False, DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool", - "add_branch", _("Create a new branch")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", - "add_variable", _("Create a new variable")), - (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", - "add_block", _("Create a new block")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", - "add_connection", _("Create a new connection"))], - "SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", - "move", _("Move the view")), - (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", - "add_comment", _("Create a new comment")), - (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool", - "add_initial_step", _("Create a new initial step")), - (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool", - "add_step", _("Create a new step")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool", - "add_transition", _("Create a new transition")), - (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", - "add_action", _("Create a new action block")), - (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool", - "add_divergence", _("Create a new divergence")), - (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool", - "add_jump", _("Create a new jump")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", - "add_variable", _("Create a new variable")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", - "add_block", _("Create a new block")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", - "add_connection", _("Create a new connection")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", - "add_powerrail", _("Create a new power rail")), - (True, FREEDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", - "add_contact", _("Create a new contact"))], - "ST" : [], - "IL" : [], + "FBD": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", + "move", _("Move the view")), + (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", + "add_comment", _("Create a new comment")), + (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", + "add_variable", _("Create a new variable")), + (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", + "add_block", _("Create a new block")), + (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", + "add_connection", _("Create a new connection"))], + "LD": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", + "move", _("Move the view")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", + "add_comment", _("Create a new comment")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", + "add_powerrail", _("Create a new power rail")), + (False, DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool", + "add_rung", _("Create a new rung")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool", + "add_coil", _("Create a new coil")), + (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", + "add_contact", _("Create a new contact")), + (False, DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool", + "add_branch", _("Create a new branch")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", + "add_variable", _("Create a new variable")), + (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", + "add_block", _("Create a new block")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", + "add_connection", _("Create a new connection"))], + "SFC": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", + "move", _("Move the view")), + (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", + "add_comment", _("Create a new comment")), + (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool", + "add_initial_step", _("Create a new initial step")), + (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool", + "add_step", _("Create a new step")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool", + "add_transition", _("Create a new transition")), + (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", + "add_action", _("Create a new action block")), + (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool", + "add_divergence", _("Create a new divergence")), + (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool", + "add_jump", _("Create a new jump")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", + "add_variable", _("Create a new variable")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", + "add_block", _("Create a new block")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", + "add_connection", _("Create a new connection")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", + "add_powerrail", _("Create a new power rail")), + (True, FREEDRAWING_MODE, + ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", + "add_contact", _("Create a new contact"))], + "ST": [], + "IL": [], "debug": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, - ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", - "move", _("Move the view"))], + ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", + "move", _("Move the view"))], } #------------------------------------------------------------------------------- @@ -885,15 +885,15 @@ def SetRefreshFunctions(self): self.RefreshFunctions = { - TITLE : self.RefreshTitle, - EDITORTOOLBAR : self.RefreshEditorToolBar, - FILEMENU : self.RefreshFileMenu, - EDITMENU : self.RefreshEditMenu, - DISPLAYMENU : self.RefreshDisplayMenu, - PROJECTTREE : self.RefreshProjectTree, - POUINSTANCEVARIABLESPANEL : self.RefreshPouInstanceVariablesPanel, - LIBRARYTREE : self.RefreshLibraryPanel, - SCALING : self.RefreshScaling, + TITLE: self.RefreshTitle, + EDITORTOOLBAR: self.RefreshEditorToolBar, + FILEMENU: self.RefreshFileMenu, + EDITMENU: self.RefreshEditMenu, + DISPLAYMENU: self.RefreshDisplayMenu, + PROJECTTREE: self.RefreshProjectTree, + POUINSTANCEVARIABLESPANEL: self.RefreshPouInstanceVariablesPanel, + LIBRARYTREE: self.RefreshLibraryPanel, + SCALING: self.RefreshScaling, PAGETITLES: self.RefreshPageTitles} ## Call PLCOpenEditor refresh functions. @@ -1874,7 +1874,7 @@ if name != "Project": new_id = wx.NewId() AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add POU")) - self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction({"Functions" : "function", "Function Blocks" : "functionBlock", "Programs" : "program"}[name]), id=new_id) + self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction({"Functions": "function", "Function Blocks": "functionBlock", "Programs": "program"}[name]), id=new_id) new_id = wx.NewId() AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Paste POU")) @@ -2557,7 +2557,7 @@ # Viewer Printout #------------------------------------------------------------------------------- -UPPER_DIV = lambda x, y: (x / y) + {True : 0, False : 1}[(x % y) == 0] +UPPER_DIV = lambda x, y: (x / y) + {True: 0, False: 1}[(x % y) == 0] class GraphicPrintout(wx.Printout): diff -r d2e979738700 -r ec153828ded2 PLCControler.py --- a/PLCControler.py Mon Aug 14 23:38:28 2017 +0300 +++ b/PLCControler.py Tue Aug 15 12:17:51 2017 +0300 @@ -1645,7 +1645,7 @@ "list": [block for block in category["list"] if block["type"] in filter]} for category in self.TotalTypes] - blocktypes.append({"name" : USER_DEFINED_POUS, + blocktypes.append({"name": USER_DEFINED_POUS, "list": [pou.getblockInfos() for pou in project.getpous(name, filter) if (name is None or @@ -1936,9 +1936,14 @@ def GetElementType(self, tagname): words = tagname.split("::") - return {"D" : ITEM_DATATYPE, "P" : ITEM_POU, - "T" : ITEM_TRANSITION, "A" : ITEM_ACTION, - "C" : ITEM_CONFIGURATION, "R" : ITEM_RESOURCE}[words[0]] + return { + "D": ITEM_DATATYPE, + "P": ITEM_POU, + "T": ITEM_TRANSITION, + "A": ITEM_ACTION, + "C": ITEM_CONFIGURATION, + "R": ITEM_RESOURCE + }[words[0]] #------------------------------------------------------------------------------- # Project opened Data types management functions diff -r d2e979738700 -r ec153828ded2 PLCGenerator.py --- a/PLCGenerator.py Mon Aug 14 23:38:28 2017 +0300 +++ b/PLCGenerator.py Tue Aug 15 12:17:51 2017 +0300 @@ -29,14 +29,14 @@ # Dictionary associating PLCOpen variable categories to the corresponding # IEC 61131-3 variable categories -varTypeNames = {"localVars" : "VAR", "tempVars" : "VAR_TEMP", "inputVars" : "VAR_INPUT", - "outputVars" : "VAR_OUTPUT", "inOutVars" : "VAR_IN_OUT", "externalVars" : "VAR_EXTERNAL", - "globalVars" : "VAR_GLOBAL", "accessVars" : "VAR_ACCESS"} +varTypeNames = {"localVars": "VAR", "tempVars": "VAR_TEMP", "inputVars": "VAR_INPUT", + "outputVars": "VAR_OUTPUT", "inOutVars": "VAR_IN_OUT", "externalVars": "VAR_EXTERNAL", + "globalVars": "VAR_GLOBAL", "accessVars": "VAR_ACCESS"} # Dictionary associating PLCOpen POU categories to the corresponding # IEC 61131-3 POU categories -pouTypeNames = {"function" : "FUNCTION", "functionBlock" : "FUNCTION_BLOCK", "program" : "PROGRAM"} +pouTypeNames = {"function": "FUNCTION", "functionBlock": "FUNCTION_BLOCK", "program": "PROGRAM"} errorVarTypes = { @@ -80,9 +80,9 @@ def JoinList(separator, mylist): """ Helper for emulate join on element list """ - if len(mylist) > 0 : + if len(mylist) > 0: return reduce(lambda x, y: x + separator + y, mylist) - else : + else: return mylist #------------------------------------------------------------------------------- @@ -187,7 +187,7 @@ for i, dimension in enumerate(basetype_content.getdimension())] datatype_def += [("ARRAY [", ())] datatype_def += JoinList([(",", ())], dimensions) - datatype_def += [("] OF " , ()), + datatype_def += [("] OF ", ()), (basetype_name, (tagname, "base"))] # Data type is a structure elif basetype_content_type == "struct": @@ -401,7 +401,7 @@ format(a1 = task.getname(), a2 = config_name, a3 = resource.getname()) raise PLCGenException, msg - if single[0]=='[' and single[-1]==']' : + if single[0]=='[' and single[-1]==']': SNGLKW = "MULTI" else: SNGLKW = "SINGLE" @@ -916,7 +916,7 @@ self.GenerateSFCJump(instance, pou) if len(self.InitialSteps) > 0 and len(self.SFCComputedBlocks) > 0: action_name = "COMPUTE_FUNCTION_BLOCKS" - action_infos = {"qualifier" : "S", "content" : action_name} + action_infos = {"qualifier": "S", "content": action_name} self.SFCNetworks["Steps"][self.InitialSteps[0]]["actions"].append(action_infos) self.SFCNetworks["Actions"][action_name] = (self.SFCComputedBlocks, ()) self.Program = [] @@ -924,7 +924,7 @@ for initialstep in self.InitialSteps: self.ComputeSFCStep(initialstep) else: - otherInstances = {"outVariables&coils" : [], "blocks" : [], "connectors" : []} + otherInstances = {"outVariables&coils": [], "blocks": [], "connectors": []} orderedInstances = [] for instance in body.getcontentInstances(): if isinstance(instance, (OutVariableClass, InOutVariableClass, BlockClass)): @@ -1358,10 +1358,10 @@ if step_name not in self.SFCNetworks["Steps"].keys(): if step.getinitialStep(): self.InitialSteps.append(step_name) - step_infos = {"id" : step.getlocalId(), - "initial" : step.getinitialStep(), - "transitions" : [], - "actions" : []} + step_infos = {"id": step.getlocalId(), + "initial": step.getinitialStep(), + "transitions": [], + "actions": []} self.SFCNetworks["Steps"][step_name] = step_infos if step.connectionPointIn is not None: instances = [] @@ -1434,10 +1434,10 @@ if step_name in self.SFCNetworks["Steps"].keys(): actions = actionBlock.getactions() for i, action in enumerate(actions): - action_infos = {"id" : actionBlock.getlocalId(), - "qualifier" : action["qualifier"], - "content" : action["value"], - "num" : i} + action_infos = {"id": actionBlock.getlocalId(), + "qualifier": action["qualifier"], + "content": action["value"], + "num": i} if "duration" in action: action_infos["duration"] = action["duration"] if "indicator" in action: @@ -1484,11 +1484,11 @@ steps.extend(self.ExtractConvergenceInputs(step, pou)) elif isinstance(instance, SimultaneousConvergenceClass): steps.extend(self.ExtractConvergenceInputs(instance, pou)) - transition_infos = {"id" : transition.getlocalId(), + transition_infos = {"id": transition.getlocalId(), "priority": transition.getpriority(), - "from": [], - "to" : [], - "content": []} + "from": [], + "to": [], + "content": []} self.SFCNetworks["Transitions"][transition] = transition_infos transitionValues = transition.getconditionContent() if transitionValues["type"] == "inline": @@ -1631,7 +1631,7 @@ program += [("\n", ())] if len(self.Interface) == 0: raise PLCGenException, _("No variable defined in \"%s\" POU") % self.Name - if len(self.Program) == 0 : + if len(self.Program) == 0: raise PLCGenException, _("No body defined in \"%s\" POU") % self.Name var_number = 0 for list_type, option, located, variables in self.Interface: diff -r d2e979738700 -r ec153828ded2 PLCOpenEditor.py --- a/PLCOpenEditor.py Mon Aug 14 23:38:28 2017 +0300 +++ b/PLCOpenEditor.py Tue Aug 15 12:17:51 2017 +0300 @@ -476,16 +476,16 @@ if result: ignored_exceptions.append(ex) info = { - 'app-title' : wx.GetApp().GetAppName(), # app_title - 'app-version' : app_version, - 'wx-version' : wx.VERSION_STRING, - 'wx-platform' : wx.Platform, - 'python-version' : platform.python_version(), #sys.version.split()[0], - 'platform' : platform.platform(), - 'e-type' : e_type, - 'e-value' : e_value, - 'date' : time.ctime(), - 'cwd' : os.getcwd(), + 'app-title': wx.GetApp().GetAppName(), # app_title + 'app-version': app_version, + 'wx-version': wx.VERSION_STRING, + 'wx-platform': wx.Platform, + 'python-version': platform.python_version(), #sys.version.split()[0], + 'platform': platform.platform(), + 'e-type': e_type, + 'e-value': e_value, + 'date': time.ctime(), + 'cwd': os.getcwd(), } if e_traceback: info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value) diff -r d2e979738700 -r ec153828ded2 POULibrary.py --- a/POULibrary.py Mon Aug 14 23:38:28 2017 +0300 +++ b/POULibrary.py Tue Aug 15 12:17:51 2017 +0300 @@ -48,7 +48,7 @@ return self.CTR() def GetTypes(self): - return {"name" : self.GetName(), "types": self.LibraryControler.Project} + return {"name": self.GetName(), "types": self.LibraryControler.Project} def GetLibraryPath(self): raise Exception("Not implemented") diff -r d2e979738700 -r ec153828ded2 ProjectController.py --- a/ProjectController.py Mon Aug 14 23:38:28 2017 +0300 +++ b/ProjectController.py Tue Aug 15 12:17:51 2017 +0300 @@ -547,7 +547,7 @@ path = os.getenv("USERPROFILE") else: path = os.getenv("HOME") - dirdialog = wx.DirDialog(self.AppFrame , _("Choose a directory to save project"), path, wx.DD_NEW_DIR_BUTTON) + dirdialog = wx.DirDialog(self.AppFrame, _("Choose a directory to save project"), path, wx.DD_NEW_DIR_BUTTON) answer = dirdialog.ShowModal() dirdialog.Destroy() if answer == wx.ID_OK: @@ -964,7 +964,7 @@ # prepare debug code variable_decl_array = [] bofs = 0 - for v in self._DbgVariablesList : + for v in self._DbgVariablesList: sz = DebugTypesSize.get(v["type"], 0) variable_decl_array += [ "{&(%(C_path)s), " % v+ @@ -1081,7 +1081,7 @@ # Build try: - if not builder.build() : + if not builder.build(): self.logger.write_error(_("C Build failed.\n")) return False except Exception, exc: @@ -1336,18 +1336,18 @@ status = "Disconnected" if(self.previous_plcstate != status): for args in { - "Started" : [("_Run", False), - ("_Stop", True)], - "Stopped" : [("_Run", True), - ("_Stop", False)], - "Empty" : [("_Run", False), - ("_Stop", False)], - "Broken" : [], - "Disconnected" :[("_Run", False), - ("_Stop", False), - ("_Transfer", False), - ("_Connect", True), - ("_Disconnect", False)], + "Started": [("_Run", False), + ("_Stop", True)], + "Stopped": [("_Run", True), + ("_Stop", False)], + "Empty": [("_Run", False), + ("_Stop", False)], + "Broken": [], + "Disconnected":[("_Run", False), + ("_Stop", False), + ("_Transfer", False), + ("_Connect", True), + ("_Disconnect", False)], }.get(status,[]): self.ShowMethod(*args) self.previous_plcstate = status @@ -1569,11 +1569,11 @@ plc_status, Traces = self._connector.GetTraceVariables() debug_getvar_retry += 1 #print [dict.keys() for IECPath, (dict, log, status, fvalue) in self.IECdebug_datas.items()] - if plc_status == "Started" : + if plc_status == "Started": if len(Traces) > 0: Failed = False self.IECdebug_lock.acquire() - for debug_tick, debug_buff in Traces : + for debug_tick, debug_buff in Traces: debug_vars = UnpackDebugBuffer(debug_buff, self.TracedIECTypes) if (debug_vars is not None and len(debug_vars) == len(self.TracedIECPath)): @@ -1795,7 +1795,7 @@ MD5 = self.GetLastBuildMD5() # Check if md5 file is empty : ask user to build PLC - if MD5 is None : + if MD5 is None: self.logger.write_error(_("Failed : Must build before transfer.\n")) return False @@ -1818,7 +1818,7 @@ builder = self.GetBuilder() if builder is not None: data = builder.GetBinaryCode() - if data is not None : + if data is not None: if self._connector.NewPLC(MD5, data, extrafiles) and self.GetIECProgramsAndVariables(): self.UnsubscribeAllDebugIECVariable() self.ProgramTransferred() @@ -1836,55 +1836,75 @@ wx.CallAfter(self.UpdateMethodsFromPLCStatus) StatusMethods = [ - {"bitmap" : "Build", - "name" : _("Build"), - "tooltip" : _("Build project into build folder"), - "method" : "_Build"}, - {"bitmap" : "Clean", - "name" : _("Clean"), - "enabled" : False, - "tooltip" : _("Clean project build folder"), - "method" : "_Clean"}, - {"bitmap" : "Run", - "name" : _("Run"), - "shown" : False, - "tooltip" : _("Start PLC"), - "method" : "_Run"}, - {"bitmap" : "Stop", - "name" : _("Stop"), - "shown" : False, - "tooltip" : _("Stop Running PLC"), - "method" : "_Stop"}, - {"bitmap" : "Connect", - "name" : _("Connect"), - "tooltip" : _("Connect to the target PLC"), - "method" : "_Connect"}, - {"bitmap" : "Transfer", - "name" : _("Transfer"), - "shown" : False, - "tooltip" : _("Transfer PLC"), - "method" : "_Transfer"}, - {"bitmap" : "Disconnect", - "name" : _("Disconnect"), - "shown" : False, - "tooltip" : _("Disconnect from PLC"), - "method" : "_Disconnect"}, - {"bitmap" : "ShowIECcode", - "name" : _("Show code"), - "shown" : False, - "tooltip" : _("Show IEC code generated by PLCGenerator"), - "method" : "_showIECcode"}, + { + "bitmap": "Build", + "name": _("Build"), + "tooltip": _("Build project into build folder"), + "method": "_Build" + }, + { + "bitmap": "Clean", + "name": _("Clean"), + "tooltip": _("Clean project build folder"), + "method": "_Clean", + "enabled": False, + }, + { + "bitmap": "Run", + "name": _("Run"), + "tooltip": _("Start PLC"), + "method": "_Run", + "shown": False, + }, + { + "bitmap": "Stop", + "name": _("Stop"), + "tooltip": _("Stop Running PLC"), + "method": "_Stop", + "shown": False, + }, + { + "bitmap": "Connect", + "name": _("Connect"), + "tooltip": _("Connect to the target PLC"), + "method": "_Connect" + }, + { + "bitmap": "Transfer", + "name": _("Transfer"), + "tooltip": _("Transfer PLC"), + "method": "_Transfer", + "shown": False, + }, + { + "bitmap": "Disconnect", + "name": _("Disconnect"), + "tooltip": _("Disconnect from PLC"), + "method": "_Disconnect", + "shown": False, + }, + { + "bitmap": "ShowIECcode", + "name": _("Show code"), + "tooltip": _("Show IEC code generated by PLCGenerator"), + "method": "_showIECcode", + "shown": False, + }, ] ConfNodeMethods = [ - {"bitmap" : "editIECrawcode", - "name" : _("Raw IEC code"), - "tooltip" : _("Edit raw IEC code added to code generated by PLCGenerator"), - "method" : "_editIECrawcode"}, - {"bitmap" : "ManageFolder", - "name" : _("Project Files"), - "tooltip" : _("Open a file explorer to manage project files"), - "method" : "_OpenProjectFiles"}, + { + "bitmap": "editIECrawcode", + "name": _("Raw IEC code"), + "tooltip": _("Edit raw IEC code added to code generated by PLCGenerator"), + "method": "_editIECrawcode" + }, + { + "bitmap": "ManageFolder", + "name": _("Project Files"), + "tooltip": _("Open a file explorer to manage project files"), + "method": "_OpenProjectFiles" + }, ] diff -r d2e979738700 -r ec153828ded2 canfestival/canfestival.py --- a/canfestival/canfestival.py Mon Aug 14 23:38:28 2017 +0300 +++ b/canfestival/canfestival.py Tue Aug 15 12:17:51 2017 +0300 @@ -178,10 +178,12 @@ dialog.Destroy() ConfNodeMethods = [ - {"bitmap" : "ExportSlave", - "name" : _("Export slave"), - "tooltip" : _("Export CanOpen slave to EDS file"), - "method" : "_ExportSlave"}, + { + "bitmap": "ExportSlave", + "name": _("Export slave"), + "tooltip": _("Export CanOpen slave to EDS file"), + "method": "_ExportSlave" + }, ] def CTNTestModified(self): @@ -228,10 +230,10 @@ # allow access to local OD from Slave PLC pointers = config_utils.LocalODPointers(locations, current_location, slave) res = gen_cfile.GenerateFile(Gen_OD_path, slave, pointers) - if res : + if res: raise Exception, res res = eds_utils.GenerateEDSFile(os.path.join(buildpath, "Slave_%s.eds" % prefix), slave) - if res : + if res: raise Exception, res return [(Gen_OD_path,local_canfestival_config.getCFLAGS(CanFestivalPath))],"",False @@ -395,10 +397,12 @@ return self._View ConfNodeMethods = [ - {"bitmap" : "ShowMaster", - "name" : _("Show Master"), - "tooltip" : _("Show Master generated by config_utils"), - "method" : "_ShowGeneratedMaster"} + { + "bitmap": "ShowMaster", + "name": _("Show Master"), + "tooltip": _("Show Master generated by config_utils"), + "method": "_ShowGeneratedMaster" + } ] def OnCloseEditor(self, view): @@ -446,7 +450,7 @@ raise Exception, e.message # Do generate C file. res = gen_cfile.GenerateFile(Gen_OD_path, master, pointers) - if res : + if res: raise Exception, res file = open(os.path.join(buildpath, "MasterGenerated.od"), "w") @@ -489,7 +493,7 @@ def GetCanDriver(self): res = self.CanFestivalInstance.getCAN_Driver() - if not res : + if not res: return "" return res @@ -497,7 +501,7 @@ can_driver = self.GetCanDriver() if can_driver is not None: can_drivers = local_canfestival_config.DLL_LIST - if can_driver not in can_drivers : + if can_driver not in can_drivers: can_driver = can_drivers[0] can_drv_ext = self.GetCTRoot().GetBuilder().extension can_drv_prefix = self.GetCTRoot().GetBuilder().dlopen_prefix @@ -506,22 +510,22 @@ can_driver_name = "" - format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())), - "candriver" : can_driver_name, - "nodes_includes" : "", - "board_decls" : "", - "nodes_init" : "", - "nodes_open" : "", - "nodes_stop" : "", - "nodes_close" : "", - "nodes_send_sync" : "", - "nodes_proceed_sync" : "", - "slavebootups" : "", - "slavebootup_register" : "", - "post_sync" : "", - "post_sync_register" : "", - "pre_op" : "", - "pre_op_register" : "", + format_dict = {"locstr": "_".join(map(str,self.GetCurrentLocation())), + "candriver": can_driver_name, + "nodes_includes": "", + "board_decls": "", + "nodes_init": "", + "nodes_open": "", + "nodes_stop": "", + "nodes_close": "", + "nodes_send_sync": "", + "nodes_proceed_sync": "", + "slavebootups": "", + "slavebootup_register": "", + "post_sync": "", + "post_sync_register": "", + "pre_op": "", + "pre_op_register": "", } for child in self.IECSortedChildren(): childlocstr = "_".join(map(str,child.GetCurrentLocation())) diff -r d2e979738700 -r ec153828ded2 canfestival/config_utils.py --- a/canfestival/config_utils.py Mon Aug 14 23:38:28 2017 +0300 +++ b/canfestival/config_utils.py Tue Aug 15 12:17:51 2017 +0300 @@ -34,14 +34,14 @@ RPDO = 1 TPDO = 2 -SlavePDOType = {"I" : TPDO, "Q" : RPDO} -InvertPDOType = {RPDO : TPDO, TPDO : RPDO} -PDOTypeBaseIndex = {RPDO : 0x1400, TPDO : 0x1800} -PDOTypeBaseCobId = {RPDO : 0x200, TPDO : 0x180} +SlavePDOType = {"I": TPDO, "Q": RPDO} +InvertPDOType = {RPDO: TPDO, TPDO: RPDO} +PDOTypeBaseIndex = {RPDO: 0x1400, TPDO: 0x1800} +PDOTypeBaseCobId = {RPDO: 0x200, TPDO: 0x180} VariableIncrement = 0x100 -VariableStartIndex = {TPDO : 0x2000, RPDO : 0x4000} -VariableDirText = {TPDO : "__I", RPDO : "__Q"} +VariableStartIndex = {TPDO: 0x2000, RPDO: 0x4000} +VariableDirText = {TPDO: "__I", RPDO: "__Q"} VariableTypeOffset = dict(zip(["","X","B","W","D","L"], range(6))) TrashVariables = [(1, 0x01), (8, 0x05), (16, 0x06), (32, 0x07), (64, 0x1B)] @@ -179,7 +179,7 @@ for PdoIdx in nodeRpdoIndexes + nodeTpdoIndexes: pdo_cobid = node.GetEntry(PdoIdx, 0x01) # Extract COB ID, if PDO isn't active - if pdo_cobid > 0x600 : + if pdo_cobid > 0x600: pdo_cobid -= 0x80000000 # Remove COB ID from the list of available COB ID if pdo_cobid in self.ListCobIDAvailable: @@ -212,7 +212,7 @@ RPDOnumber, TPDOnumber = self.RemoveUsedNodeCobId(self.MasterNode) # Store the indexes of the first RPDO and TPDO available for MasterNode - self.CurrentPDOParamsIdx = {RPDO : 0x1400 + RPDOnumber, TPDO : 0x1800 + TPDOnumber} + self.CurrentPDOParamsIdx = {RPDO: 0x1400 + RPDOnumber, TPDO: 0x1800 + TPDOnumber} # Prepare MasterNode with all nodelist slaves for idx, (nodeid, nodeinfos) in enumerate(self.NodeList.SlaveNodes.items()): @@ -307,8 +307,8 @@ @param pdomapping: list od variables to map with PDO """ # Add an entry to MasterMapping - self.MasterMapping[pdocobid] = {"type" : InvertPDOType[pdotype], - "mapping" : [None] + [(loc_infos["type"], name) for name, loc_infos in pdomapping]} + self.MasterMapping[pdocobid] = {"type": InvertPDOType[pdotype], + "mapping": [None] + [(loc_infos["type"], name) for name, loc_infos in pdomapping]} # Return the data to add to DCF if sync_TPDOs: @@ -381,7 +381,7 @@ if location["IEC_TYPE"] != "BOOL" and subentry_infos["type"] != COlocationtype: raise PDOmappingException, _("Invalid type \"{a1}\"-> {a2} != {a3} for location \"{a4}\"").\ - format(a1 = location["IEC_TYPE"], a2 = COlocationtype, a3 = subentry_infos["type"] , a4 = name) + format(a1 = location["IEC_TYPE"], a2 = COlocationtype, a3 = subentry_infos["type"], a4 = name) typeinfos = node.GetEntryInfos(COlocationtype) self.IECLocations[name] = {"type":COlocationtype, "pdotype":SlavePDOType[direction], @@ -426,7 +426,7 @@ for value in values[1:]: if value != 0: mapping.append(value % 0x100) - self.MasterMapping[cobid] = {"type" : InvertPDOType[locationinfos["pdotype"]], "mapping" : mapping} + self.MasterMapping[cobid] = {"type": InvertPDOType[locationinfos["pdotype"]], "mapping": mapping} # Indicate that this PDO entry must be saved if locationinfos["bit"] is not None: @@ -440,7 +440,7 @@ else: # Add location to those that haven't been mapped yet if locationinfos["nodeid"] not in self.LocationsNotMapped.keys(): - self.LocationsNotMapped[locationinfos["nodeid"]] = {TPDO : [], RPDO : []} + self.LocationsNotMapped[locationinfos["nodeid"]] = {TPDO: [], RPDO: []} self.LocationsNotMapped[locationinfos["nodeid"]][locationinfos["pdotype"]].append((name, locationinfos)) #------------------------------------------------------------------------------- @@ -582,8 +582,8 @@ self.Manager.AddSubentriesToCurrent(mapvariableidx, 1, self.MasterNode) nbsubentries += 1 # Add informations to the new subentry created - self.MasterNode.SetMappingEntry(mapvariableidx, nbsubentries, values = {"name" : subindexname}) - self.MasterNode.SetMappingEntry(mapvariableidx, nbsubentries, values = {"type" : typeidx}) + self.MasterNode.SetMappingEntry(mapvariableidx, nbsubentries, values = {"name": subindexname}) + self.MasterNode.SetMappingEntry(mapvariableidx, nbsubentries, values = {"type": typeidx}) # Set value of the PDO mapping typeinfos = self.Manager.GetEntryInfos(typeidx) @@ -647,7 +647,7 @@ subentry_infos = slave.GetSubentryInfos(index, subindex) if subentry_infos["type"] != COlocationtype: raise PDOmappingException, _("Invalid type \"{a1}\"-> {a2} != {a3} for location \"{a4}\"").\ - format( a1 = location["IEC_TYPE"], a2 = COlocationtype, a3 = subentry_infos["type"] , a4 = name) + format( a1 = location["IEC_TYPE"], a2 = COlocationtype, a3 = subentry_infos["type"], a4 = name) IECLocations[name] = COlocationtype pointers[(index, subindex)] = name diff -r d2e979738700 -r ec153828ded2 connectors/WAMP/__init__.py --- a/connectors/WAMP/__init__.py Mon Aug 14 23:38:28 2017 +0300 +++ b/connectors/WAMP/__init__.py Tue Aug 15 12:17:51 2017 +0300 @@ -52,10 +52,10 @@ _WampSession = None print 'WAMP session left' -PLCObjDefaults = { "StartPLC": False, - "GetTraceVariables" : ("Broken",None), - "GetPLCstatus" : ("Broken",None), - "RemoteExec" : (-1, "RemoteExec script failed!")} +PLCObjDefaults = { "StartPLC": False, + "GetTraceVariables": ("Broken", None), + "GetPLCstatus": ("Broken", None), + "RemoteExec": (-1, "RemoteExec script failed!")} def WAMP_connector_factory(uri, confnodesroot): @@ -106,7 +106,7 @@ wampfuncname = '.'.join((ID,funcname)) def catcher_func(*args,**kwargs): global _WampSession - if _WampSession is not None : + if _WampSession is not None: try: return threads.blockingCallFromThread( reactor, _WampSession.call, wampfuncname, @@ -148,7 +148,7 @@ return member # Try to get the proxy object - try : + try: return WampPLCObjectProxy() except Exception, msg: confnodesroot.logger.write_error(_("WAMP connection to '%s' failed.\n") % location) diff -r d2e979738700 -r ec153828ded2 controls/CustomStyledTextCtrl.py --- a/controls/CustomStyledTextCtrl.py Mon Aug 14 23:38:28 2017 +0300 +++ b/controls/CustomStyledTextCtrl.py Tue Aug 15 12:17:51 2017 +0300 @@ -27,17 +27,17 @@ if wx.Platform == '__WXMSW__': faces = { 'times': 'Times New Roman', - 'mono' : 'Courier New', - 'helv' : 'Arial', + 'mono': 'Courier New', + 'helv': 'Arial', 'other': 'Comic Sans MS', - 'size' : 10, + 'size': 10, } else: faces = { 'times': 'Times', - 'mono' : 'Courier', - 'helv' : 'Helvetica', + 'mono': 'Courier', + 'helv': 'Helvetica', 'other': 'new century schoolbook', - 'size' : 12, + 'size': 12, } NAVIGATION_KEYS = [ diff -r d2e979738700 -r ec153828ded2 controls/LibraryPanel.py --- a/controls/LibraryPanel.py Mon Aug 14 23:38:28 2017 +0300 +++ b/controls/LibraryPanel.py Tue Aug 15 12:17:51 2017 +0300 @@ -212,7 +212,7 @@ # Set data associated to tree item (only save that item is a # category) - self.Tree.SetPyData(category_item, {"type" : CATEGORY}) + self.Tree.SetPyData(category_item, {"type": CATEGORY}) # Iterate over functions and function blocks defined in library # category add a tree item to category tree item for each of @@ -239,16 +239,16 @@ # Define data to associate to block tree item comment = blocktype["comment"] - block_data = {"type" : BLOCK, - "block_type" : blocktype["type"], - "inputs" : tuple([type - for name, type, modifier - in blocktype["inputs"]]), - "extension" : (len(blocktype["inputs"]) - if blocktype["extensible"] - else None), - "comment": _(comment) + - blocktype.get("usage", "")} + block_data = { + "type": BLOCK, + "block_type": blocktype["type"], + "inputs": tuple([type + for name, type, modifier + in blocktype["inputs"]]), + "extension": (len(blocktype["inputs"]) + if blocktype["extensible"] else None), + "comment": _(comment) + blocktype.get("usage", "") + } self.Tree.SetPyData(blocktype_item, block_data) # Select block tree item in tree if it corresponds to diff -r d2e979738700 -r ec153828ded2 controls/SearchResultPanel.py --- a/controls/SearchResultPanel.py Mon Aug 14 23:38:28 2017 +0300 +++ b/controls/SearchResultPanel.py Tue Aug 15 12:17:51 2017 +0300 @@ -219,7 +219,7 @@ child_name = GenerateName(infos[3:]) child_infos = {"name": child_name, "type": child_type, - "data": (infos, start, end ,None), + "data": (infos, start, end, None), "text": text, "matches": 1, "children": [], diff -r d2e979738700 -r ec153828ded2 controls/VariablePanel.py --- a/controls/VariablePanel.py Mon Aug 14 23:38:28 2017 +0300 +++ b/controls/VariablePanel.py Tue Aug 15 12:17:51 2017 +0300 @@ -49,14 +49,14 @@ def GetVariableTableColnames(location): - _ = lambda x : x + _ = lambda x: x if location: return ["#", _("Name"), _("Class"), _("Type"), _("Location"), _("Initial Value"), _("Option"), _("Documentation")] return ["#", _("Name"), _("Class"), _("Type"), _("Initial Value"), _("Option"), _("Documentation")] def GetOptions(constant=True, retain=True, non_retain=True): - _ = lambda x : x + _ = lambda x: x options = [""] if constant: options.append(_("Constant")) @@ -69,7 +69,7 @@ def GetFilterChoiceTransfer(): - _ = lambda x : x + _ = lambda x: x return {_("All"): _("All"), _("Interface"): _("Interface"), _(" Input"): _("Input"), _(" Output"): _("Output"), _(" InOut"): _("InOut"), _(" External"): _("External"), _("Variables"): _("Variables"), _(" Local"): _("Local"), @@ -122,7 +122,7 @@ value = getattr(self.data[row], colname, "") if colname == "Type" and isinstance(value, TupleType): if value[0] == "array": - return "ARRAY [%s] OF %s" % (",".join(map(lambda x : "..".join(x), value[2])), value[1]) + return "ARRAY [%s] OF %s" % (",".join(map(lambda x: "..".join(x), value[2])), value[1]) if not isinstance(value, (StringType, UnicodeType)): value = str(value) if colname in ["Class", "Option"]: @@ -389,7 +389,7 @@ if element_type in ["functionBlock","program"]: var_infos.Class = "Local" var_infos.InitialValue = values[0] - else : + else: return else: var_infos.Class = "External" @@ -491,9 +491,9 @@ self.DefaultValue = _VariableInfos("", "", "", "", "", True, "", DefaultType, ([], []), 0) if element_type in ["config", "resource"]: - self.DefaultTypes = {"All" : "Global"} - else: - self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"} + self.DefaultTypes = {"All": "Global"} + else: + self.DefaultTypes = {"All": "Local", "Interface": "Input", "Variables": "Local"} if element_type in ["config", "resource"] \ or element_type in ["program", "transition", "action"]: diff -r d2e979738700 -r ec153828ded2 dialogs/ArrayTypeDialog.py --- a/dialogs/ArrayTypeDialog.py Mon Aug 14 23:38:28 2017 +0300 +++ b/dialogs/ArrayTypeDialog.py Tue Aug 15 12:17:51 2017 +0300 @@ -83,7 +83,7 @@ if isinstance(infos, TupleType) and infos[0] == "array": self.BaseType.SetStringSelection(infos[1]) - self.Dimensions.SetStrings(map(lambda x : "..".join(x), infos[2])) + self.Dimensions.SetStrings(map(lambda x: "..".join(x), infos[2])) elif infos in datatypes: self.BaseType.SetStringSelection(infos) diff -r d2e979738700 -r ec153828ded2 dialogs/BrowseLocationsDialog.py --- a/dialogs/BrowseLocationsDialog.py Mon Aug 14 23:38:28 2017 +0300 +++ b/dialogs/BrowseLocationsDialog.py Tue Aug 15 12:17:51 2017 +0300 @@ -37,7 +37,7 @@ def GetDirFilterChoiceOptions(): - _ = lambda x : x + _ = lambda x: x return [(_("All"), [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]), (_("Input"), [LOCATION_VAR_INPUT]), (_("Output"), [LOCATION_VAR_OUTPUT]), @@ -46,7 +46,7 @@ def GetTypeFilterChoiceOptions(): - _ = lambda x : x + _ = lambda x: x return [_("All"), _("Type and derivated"), _("Type strict")] diff -r d2e979738700 -r ec153828ded2 dialogs/DiscoveryDialog.py --- a/dialogs/DiscoveryDialog.py Mon Aug 14 23:38:28 2017 +0300 +++ b/dialogs/DiscoveryDialog.py Tue Aug 15 12:17:51 2017 +0300 @@ -139,11 +139,11 @@ self.LatestSelection=None def __del__(self): - if self.Browser is not None : self.Browser.cancel() + if self.Browser is not None: self.Browser.cancel() self.ZeroConfInstance.close() def RefreshList(self): - if self.Browser is not None : self.Browser.cancel() + if self.Browser is not None: self.Browser.cancel() self.Browser = ServiceBrowser(self.ZeroConfInstance, service_type, self) def OnRefreshButton(self, event): @@ -157,7 +157,7 @@ def OnIpButton(self, event): if self.LatestSelection is not None: - l = lambda col : self.getColumnText(self.LatestSelection,col) + l = lambda col: self.getColumnText(self.LatestSelection,col) self.URI = "%s://%s:%s" % tuple(map(l,(1,2,3))) self.EndModal(wx.ID_OK) event.Skip() diff -r d2e979738700 -r ec153828ded2 dialogs/FBDVariableDialog.py --- a/dialogs/FBDVariableDialog.py Mon Aug 14 23:38:28 2017 +0300 +++ b/dialogs/FBDVariableDialog.py Tue Aug 15 12:17:51 2017 +0300 @@ -35,9 +35,12 @@ # Dictionaries containing correspondence between variable block class and string # to be shown in Class combo box in both sense -VARIABLE_CLASSES_DICT = {INPUT : _("Input"), - INOUT : _("InOut"), - OUTPUT : _("Output")} +VARIABLE_CLASSES_DICT = { + INPUT: _("Input"), + INOUT: _("InOut"), + OUTPUT: _("Output") +} + VARIABLE_CLASSES_DICT_REVERSE = dict( [(value, key) for key, value in VARIABLE_CLASSES_DICT.iteritems()]) diff -r d2e979738700 -r ec153828ded2 dialogs/ForceVariableDialog.py --- a/dialogs/ForceVariableDialog.py Mon Aug 14 23:38:28 2017 +0300 +++ b/dialogs/ForceVariableDialog.py Tue Aug 15 12:17:51 2017 +0300 @@ -30,11 +30,11 @@ # Helpers #------------------------------------------------------------------------------- -LOCATIONDATATYPES = {"X" : ["BOOL"], - "B" : ["SINT", "USINT", "BYTE", "STRING"], - "W" : ["INT", "UINT", "WORD", "WSTRING"], - "D" : ["DINT", "UDINT", "REAL", "DWORD"], - "L" : ["LINT", "ULINT", "LREAL", "LWORD"]} +LOCATIONDATATYPES = {"X": ["BOOL"], + "B": ["SINT", "USINT", "BYTE", "STRING"], + "W": ["INT", "UINT", "WORD", "WSTRING"], + "D": ["DINT", "UDINT", "REAL", "DWORD"], + "L": ["LINT", "ULINT", "LREAL", "LWORD"]} def gen_get_function(f): diff -r d2e979738700 -r ec153828ded2 dialogs/PouActionDialog.py --- a/dialogs/PouActionDialog.py Mon Aug 14 23:38:28 2017 +0300 +++ b/dialogs/PouActionDialog.py Tue Aug 15 12:17:51 2017 +0300 @@ -29,7 +29,7 @@ def GetActionLanguages(): - _ = lambda x : x + _ = lambda x: x return [_("IL"), _("ST"), _("LD"), _("FBD")] ACTION_LANGUAGES_DICT = dict([(_(language), language) for language in GetActionLanguages()]) diff -r d2e979738700 -r ec153828ded2 dialogs/PouDialog.py --- a/dialogs/PouDialog.py Mon Aug 14 23:38:28 2017 +0300 +++ b/dialogs/PouDialog.py Tue Aug 15 12:17:51 2017 +0300 @@ -29,13 +29,13 @@ def GetPouTypes(): - _ = lambda x : x + _ = lambda x: x return [_("function"), _("functionBlock"), _("program")] POU_TYPES_DICT = dict([(_(pou_type), pou_type) for pou_type in GetPouTypes()]) def GetPouLanguages(): - _ = lambda x : x + _ = lambda x: x return [_("IL"), _("ST"), _("LD"), _("FBD"), _("SFC")] diff -r d2e979738700 -r ec153828ded2 dialogs/PouTransitionDialog.py --- a/dialogs/PouTransitionDialog.py Mon Aug 14 23:38:28 2017 +0300 +++ b/dialogs/PouTransitionDialog.py Tue Aug 15 12:17:51 2017 +0300 @@ -33,7 +33,7 @@ def GetTransitionLanguages(): - _ = lambda x : x + _ = lambda x: x return [_("IL"), _("ST"), _("LD"), _("FBD")] TRANSITION_LANGUAGES_DICT = dict([(_(language), language) for language in GetTransitionLanguages()]) diff -r d2e979738700 -r ec153828ded2 dialogs/SFCTransitionDialog.py --- a/dialogs/SFCTransitionDialog.py Mon Aug 14 23:38:28 2017 +0300 +++ b/dialogs/SFCTransitionDialog.py Tue Aug 15 12:17:51 2017 +0300 @@ -161,7 +161,7 @@ Return SFC transition parameters defined in dialog @return: {parameter_name: parameter_value,...} """ - values = {"priority" : self.Priority.GetValue()} + values = {"priority": self.Priority.GetValue()} values["type"], values["value"] = self.GetTransitionType() values["width"], values["height"] = self.Element.GetSize() return values diff -r d2e979738700 -r ec153828ded2 docutil/docpdf.py --- a/docutil/docpdf.py Mon Aug 14 23:38:28 2017 +0300 +++ b/docutil/docpdf.py Tue Aug 15 12:17:51 2017 +0300 @@ -48,14 +48,14 @@ def open_win_pdf(readerexepath, pdffile, pagenum = None): - if pagenum != None : + if pagenum != 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 == None: os.system("%s -remote DS301 %s &" % (readerexepath, pdffile)) else: print "Open pdf %s at page %d" % (pdffile, pagenum) @@ -63,7 +63,7 @@ def open_pdf(pdffile, pagenum = None): - if wx.Platform == '__WXMSW__' : + if wx.Platform == '__WXMSW__': try: readerpath = get_acroversion() except: diff -r d2e979738700 -r ec153828ded2 docutil/docsvg.py --- a/docutil/docsvg.py Mon Aug 14 23:38:28 2017 +0300 +++ b/docutil/docsvg.py Tue Aug 15 12:17:51 2017 +0300 @@ -39,7 +39,7 @@ def open_win_svg(svgexepath, svgfile): """ Open Inkscape on Windows platform """ popenargs = [svgexepath] - if svgfile is not None : + if svgfile is not None: popenargs.append(svgfile) subprocess.Popen(popenargs).pid @@ -47,12 +47,12 @@ def open_lin_svg(svgexepath, svgfile): """ Open Inkscape on Linux platform """ if os.path.isfile("/usr/bin/inkscape"): - os.system("%s %s &" % (svgexepath , svgfile)) + os.system("%s %s &" % (svgexepath, svgfile)) def open_svg(svgfile): """ Generic function to open SVG file """ - if wx.Platform == '__WXMSW__' : + if wx.Platform == '__WXMSW__': try: open_win_svg(get_inkscape_path(), svgfile) except: diff -r d2e979738700 -r ec153828ded2 editors/CodeFileEditor.py --- a/editors/CodeFileEditor.py Mon Aug 14 23:38:28 2017 +0300 +++ b/editors/CodeFileEditor.py Tue Aug 15 12:17:51 2017 +0300 @@ -677,7 +677,7 @@ self.ParentWindow = window self.Controler = controler - self.VariablesDefaultValue = {"Name" : "", "Type" : DefaultType, "Initial": "", + self.VariablesDefaultValue = {"Name": "", "Type": DefaultType, "Initial": "", "Description":"", "OnChange":"", "Options":""} self.Table = VariablesTable(self, [], self.GetVariableTableColnames()) self.ColAlignements = [wx.ALIGN_RIGHT] + \ @@ -736,7 +736,7 @@ self.Table.ResetView(self.VariablesGrid) def GetVariableTableColnames(self): - _ = lambda x : x + _ = lambda x: x return ["#", _("Name"),_("Type"), _("Initial"), _("Description"), _("OnChange"), _("Options")] def RefreshModel(self): diff -r d2e979738700 -r ec153828ded2 editors/ConfTreeNodeEditor.py --- a/editors/ConfTreeNodeEditor.py Mon Aug 14 23:38:28 2017 +0300 +++ b/editors/ConfTreeNodeEditor.py Tue Aug 15 12:17:51 2017 +0300 @@ -38,17 +38,17 @@ if wx.Platform == '__WXMSW__': faces = { 'times': 'Times New Roman', - 'mono' : 'Courier New', - 'helv' : 'Arial', + 'mono': 'Courier New', + 'helv': 'Arial', 'other': 'Comic Sans MS', - 'size' : 16, + 'size': 16, } else: faces = { 'times': 'Times', - 'mono' : 'Courier', - 'helv' : 'Helvetica', + 'mono': 'Courier', + 'helv': 'Helvetica', 'other': 'new century schoolbook', - 'size' : 18, + 'size': 18, } SCROLLBAR_UNIT = 10 diff -r d2e979738700 -r ec153828ded2 editors/DataTypeEditor.py --- a/editors/DataTypeEditor.py Mon Aug 14 23:38:28 2017 +0300 +++ b/editors/DataTypeEditor.py Tue Aug 15 12:17:51 2017 +0300 @@ -48,12 +48,12 @@ def GetElementsTableColnames(): - _ = lambda x : x + _ = lambda x: x return ["#", _("Name"), _("Type"), _("Initial Value")] def GetDatatypeTypes(): - _ = lambda x : x + _ = lambda x: x return [_("Directly"), _("Subrange"), _("Enumerated"), _("Array"), _("Structure")] DATATYPE_TYPES_DICT = dict([(_(datatype), datatype) for datatype in GetDatatypeTypes()]) @@ -81,7 +81,7 @@ if colname == "Type" and isinstance(value, TupleType): if value[0] == "array": - return "ARRAY [%s] OF %s" % (",".join(map(lambda x : "..".join(x), value[2])), value[1]) + return "ARRAY [%s] OF %s" % (",".join(map(lambda x: "..".join(x), value[2])), value[1]) return value def SetValue(self, row, col, value): @@ -379,7 +379,7 @@ def __init__(self, parent, tagname, window, controler): EditorPanel.__init__(self, parent, tagname, window, controler) - self.StructureElementDefaultValue = {"Name" : "", "Type" : DefaultType, "Initial Value" : ""} + self.StructureElementDefaultValue = {"Name": "", "Type": DefaultType, "Initial Value": ""} self.StructureElementsTable = ElementsTable(self, [], GetElementsTableColnames()) self.StructureColSizes = [40, 150, 100, 250] self.StructureColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] @@ -501,7 +501,7 @@ self.EnumeratedInitialValue.SetStringSelection(type_infos["initial"]) elif type_infos["type"] == "Array": self.ArrayBaseType.SetStringSelection(type_infos["base_type"]) - self.ArrayDimensions.SetStrings(map(lambda x : "..".join(x), type_infos["dimensions"])) + self.ArrayDimensions.SetStrings(map(lambda x: "..".join(x), type_infos["dimensions"])) self.ArrayInitialValue.SetValue(type_infos["initial"]) elif type_infos["type"] == "Structure": self.StructureElementsTable.SetData(type_infos["elements"]) @@ -723,7 +723,7 @@ def RefreshTypeInfos(self): selected = DATATYPE_TYPES_DICT[self.DerivationType.GetStringSelection()] - infos = {"type" : selected} + infos = {"type": selected} if selected == "Directly": infos["base_type"] = self.DirectlyBaseType.GetStringSelection() infos["initial"] = self.DirectlyInitialValue.GetValue() @@ -795,7 +795,7 @@ self.StructureElementsTable.ClearHighlights(highlight_type) self.RefreshView() - def AddHighlight(self, infos, start, end ,highlight_type): + def AddHighlight(self, infos, start, end, highlight_type): self.Highlights.append((infos, start, end, highlight_type)) self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) diff -r d2e979738700 -r ec153828ded2 editors/ResourceEditor.py --- a/editors/ResourceEditor.py Mon Aug 14 23:38:28 2017 +0300 +++ b/editors/ResourceEditor.py Tue Aug 15 12:17:51 2017 +0300 @@ -65,16 +65,16 @@ #------------------------------------------------------------------------------- def GetTasksTableColnames(): - _ = lambda x : x + _ = lambda x: x return [_("Name"), _("Triggering"), _("Single"), _("Interval"), _("Priority")] def GetTaskTriggeringOptions(): - _ = lambda x : x + _ = lambda x: x return [_("Interrupt"), _("Cyclic")] TASKTRIGGERINGOPTIONS_DICT = dict([(_(option), option) for option in GetTaskTriggeringOptions()]) -SingleCellEditor = lambda *x : wx.grid.GridCellChoiceEditor() +SingleCellEditor = lambda *x: wx.grid.GridCellChoiceEditor() def CheckSingle(single, varlist): @@ -82,7 +82,7 @@ def GetInstancesTableColnames(): - _ = lambda x : x + _ = lambda x: x return [_("Name"), _("Type"), _("Task")] @@ -292,7 +292,7 @@ self.RefreshHighlightsTimer = wx.Timer(self, -1) self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer) - self.TasksDefaultValue = {"Name" : "", "Triggering" : "", "Single" : "", "Interval" : "", "Priority" : 0} + self.TasksDefaultValue = {"Name": "", "Triggering": "", "Single": "", "Interval": "", "Priority": 0} self.TasksTable = ResourceTable(self, [], GetTasksTableColnames()) self.TasksTable.SetColAlignements([wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT]) self.TasksTable.SetColSizes([200, 100, 100, 150, 100]) @@ -327,7 +327,7 @@ self.TasksTable.ResetView(self.TasksGrid) self.TasksGrid.RefreshButtons() - self.InstancesDefaultValue = {"Name" : "", "Type" : "", "Task" : ""} + self.InstancesDefaultValue = {"Name": "", "Type": "", "Task": ""} self.InstancesTable = ResourceTable(self, [], GetInstancesTableColnames()) self.InstancesTable.SetColAlignements([wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT]) self.InstancesTable.SetColSizes([200, 150, 150]) @@ -486,7 +486,7 @@ message = _("\"%s\" is not a valid identifier!") % value elif value.upper() in IEC_KEYWORDS: message = _("\"%s\" is a keyword. It can't be used!") % value - elif value.upper() in [var["Name"].upper() for i ,var in enumerate(self.InstancesTable.data) if i!=row]: + elif value.upper() in [var["Name"].upper() for i, var in enumerate(self.InstancesTable.data) if i!=row]: message = _("An instance with the same name already exists!") if message is not None: event.Veto() diff -r d2e979738700 -r ec153828ded2 editors/Viewer.py --- a/editors/Viewer.py Mon Aug 14 23:38:28 2017 +0300 +++ b/editors/Viewer.py Tue Aug 15 12:17:51 2017 +0300 @@ -66,17 +66,17 @@ if wx.Platform == '__WXMSW__': faces = { 'times': 'Times New Roman', - 'mono' : 'Courier New', - 'helv' : 'Arial', + 'mono': 'Courier New', + 'helv': 'Arial', 'other': 'Comic Sans MS', - 'size' : 10, + 'size': 10, } else: faces = { 'times': 'Times', - 'mono' : 'Courier', - 'helv' : 'Helvetica', + 'mono': 'Courier', + 'helv': 'Helvetica', 'other': 'new century schoolbook', - 'size' : 12, + 'size': 12, } if wx.Platform == '__WXMSW__': @@ -1359,7 +1359,7 @@ def loadInstance(self, instance, remaining_instances, selection): self.current_id = max(self.current_id, instance.id) creation_function = ElementCreationFunctions.get(instance.type, None) - connectors = {"inputs" : [], "outputs" : []} + connectors = {"inputs": [], "outputs": []} specific_values = instance.specific_values if creation_function is not None: element = creation_function(self, instance.id, specific_values) @@ -2005,7 +2005,7 @@ if element is None or element.TestHandle(event) == (0, 0): connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection()) if connector is not None: - event.Dragging = lambda : True + event.Dragging = lambda: True self.SelectedElement.OnMotion(event, dc, self.Scaling) if self.SelectedElement.EndConnected is not None: self.SelectedElement.ResetPoints() @@ -2797,12 +2797,14 @@ dialog = FBDBlockDialog(self.ParentWindow, self.Controler, self.TagName) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinElementSize(block.GetSize()) - old_values = {"name" : block.GetName(), - "type" : block.GetType(), - "extension" : block.GetExtension(), - "inputs" : block.GetInputTypes(), - "executionControl" : block.GetExecutionControl(), - "executionOrder" : block.GetExecutionOrder()} + old_values = { + "name": block.GetName(), + "type": block.GetType(), + "extension": block.GetExtension(), + "inputs": block.GetInputTypes(), + "executionControl": block.GetExecutionControl(), + "executionOrder": block.GetExecutionOrder() + } dialog.SetValues(old_values) if dialog.ShowModal() == wx.ID_OK: new_values = dialog.GetValues() @@ -2831,8 +2833,11 @@ dialog = FBDVariableDialog(self.ParentWindow, self.Controler, self.TagName) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinElementSize(variable.GetSize()) - old_values = {"expression" : variable.GetName(), "class" : variable.GetType(), - "executionOrder" : variable.GetExecutionOrder()} + old_values = { + "expression": variable.GetName(), + "class": variable.GetType(), + "executionOrder": variable.GetExecutionOrder() + } dialog.SetValues(old_values) if dialog.ShowModal() == wx.ID_OK: new_values = dialog.GetValues() @@ -2860,7 +2865,7 @@ dialog = ConnectionDialog(self.ParentWindow, self.Controler, self.TagName, True) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinElementSize(connection.GetSize()) - values = {"name" : connection.GetName(), "type" : connection.GetType()} + values = {"name": connection.GetName(), "type": connection.GetType()} dialog.SetValues(values) result = dialog.ShowModal() dialog.Destroy() @@ -2892,8 +2897,8 @@ dialog = LDElementDialog(self.ParentWindow, self.Controler, self.TagName, "contact") dialog.SetPreviewFont(self.GetFont()) dialog.SetMinElementSize(contact.GetSize()) - dialog.SetValues({"variable" : contact.GetName(), - "modifier" : contact.GetType()}) + dialog.SetValues({"variable": contact.GetName(), + "modifier": contact.GetType()}) if dialog.ShowModal() == wx.ID_OK: values = dialog.GetValues() rect = contact.GetRedrawRect(1, 1) @@ -2912,8 +2917,8 @@ dialog = LDElementDialog(self.ParentWindow, self.Controler, self.TagName, "coil") dialog.SetPreviewFont(self.GetFont()) dialog.SetMinElementSize(coil.GetSize()) - dialog.SetValues({"variable" : coil.GetName(), - "modifier" : coil.GetType()}) + dialog.SetValues({"variable": coil.GetName(), + "modifier": coil.GetType()}) if dialog.ShowModal() == wx.ID_OK: values = dialog.GetValues() rect = coil.GetRedrawRect(1, 1) @@ -2960,7 +2965,7 @@ dialog.SetMinElementSize(step.GetSize()) connectors = step.GetConnectors() dialog.SetValues({ - "name" : step.GetName(), + "name": step.GetName(), "input": len(connectors["inputs"]) > 0, "output": len(connectors["outputs"]) > 0, "action": step.GetActionConnector() != None}) diff -r d2e979738700 -r ec153828ded2 graphics/FBD_Objects.py --- a/graphics/FBD_Objects.py Mon Aug 14 23:38:28 2017 +0300 +++ b/graphics/FBD_Objects.py Tue Aug 15 12:17:51 2017 +0300 @@ -220,7 +220,7 @@ # Returns all the block connectors def GetConnectors(self): - return {"inputs" : self.Inputs, "outputs" : self.Outputs} + return {"inputs": self.Inputs, "outputs": self.Outputs} # Test if point given is on one of the block connectors def TestConnector(self, pt, direction = None, exclude = True): @@ -420,7 +420,7 @@ return self.Description # Adds an highlight to the block - def AddHighlight(self, infos, start, end ,highlight_type): + def AddHighlight(self, infos, start, end, highlight_type): if infos[0] in ["type", "name"] and start[0] == 0 and end[0] == 0: highlights = self.Highlights.setdefault(infos[0], []) AddHighlight(highlights, (start, end, highlight_type)) @@ -843,7 +843,7 @@ return connection def GetConnectorTranslation(self, element): - return {self.Connector : element.Connector} + return {self.Connector: element.Connector} # Unconnect connector def Clean(self): diff -r d2e979738700 -r ec153828ded2 graphics/GraphicCommons.py --- a/graphics/GraphicCommons.py Mon Aug 14 23:38:28 2017 +0300 +++ b/graphics/GraphicCommons.py Tue Aug 15 12:17:51 2017 +0300 @@ -105,14 +105,14 @@ REFRESH_HIGHLIGHT_PERIOD = 0.1 HANDLE_CURSORS = { - (1, 1) : 2, - (3, 3) : 2, - (1, 3) : 3, - (3, 1) : 3, - (1, 2) : 4, - (3, 2) : 4, - (2, 1) : 5, - (2, 3) : 5 + (1, 1): 2, + (3, 3): 2, + (1, 3): 3, + (3, 1): 3, + (1, 2): 4, + (3, 2): 4, + (2, 1): 5, + (2, 3): 5 } diff -r d2e979738700 -r ec153828ded2 graphics/LD_Objects.py --- a/graphics/LD_Objects.py Mon Aug 14 23:38:28 2017 +0300 +++ b/graphics/LD_Objects.py Tue Aug 15 12:17:51 2017 +0300 @@ -249,7 +249,7 @@ position = connector.GetRelPosition() self.RealConnectors.append(max(0., min(float(position.y - self.Extensions[0]) / float(height), 1.))) elif len(self.Connectors) > 1: - self.RealConnectors = map(lambda x : x * 1 / (len(self.Connectors) - 1), xrange(len(self.Connectors))) + self.RealConnectors = map(lambda x: x * 1 / (len(self.Connectors) - 1), xrange(len(self.Connectors))) else: self.RealConnectors = [0.5] Graphic_Element.OnLeftDown(self, event, dc, scaling) @@ -428,7 +428,7 @@ return contact def GetConnectorTranslation(self, element): - return {self.Input : element.Input, self.Output : element.Output} + return {self.Input: element.Input, self.Output: element.Output} # Returns the RedrawRect def GetRedrawRect(self, movex = 0, movey = 0): @@ -743,7 +743,7 @@ return coil def GetConnectorTranslation(self, element): - return {self.Input : element.Input, self.Output : element.Output} + return {self.Input: element.Input, self.Output: element.Output} # Returns the RedrawRect def GetRedrawRect(self, movex = 0, movey = 0): diff -r d2e979738700 -r ec153828ded2 graphics/SFC_Objects.py --- a/graphics/SFC_Objects.py Mon Aug 14 23:38:28 2017 +0300 +++ b/graphics/SFC_Objects.py Tue Aug 15 12:17:51 2017 +0300 @@ -646,7 +646,7 @@ return transition def GetConnectorTranslation(self, element): - connectors = {self.Input : element.Input, self.Output : element.Output} + connectors = {self.Input: element.Input, self.Output: element.Output} if self.Type == "connection" and self.Condition is not None: connectors[self.Condition] = element.Condition return connectors @@ -953,7 +953,7 @@ self.Output.RefreshWires() # Adds an highlight to the block - def AddHighlight(self, infos, start, end ,highlight_type): + def AddHighlight(self, infos, start, end, highlight_type): if infos[0] in ["reference", "inline", "priority"] and start[0] == 0 and end[0] == 0: highlights = self.Highlights.setdefault(infos[0], []) AddHighlight(highlights, (start, end, highlight_type)) @@ -1544,7 +1544,7 @@ return jump def GetConnectorTranslation(self, element): - return {self.Input : element.Input} + return {self.Input: element.Input} # Returns the RedrawRect def GetRedrawRect(self, movex = 0, movey = 0): @@ -1822,7 +1822,7 @@ return action_block def GetConnectorTranslation(self, element): - return {self.Input : element.Input} + return {self.Input: element.Input} # Returns the RedrawRect def GetRedrawRect(self, movex = 0, movey = 0): diff -r d2e979738700 -r ec153828ded2 i18n/mki18n.py --- a/i18n/mki18n.py Mon Aug 14 23:38:28 2017 +0300 +++ b/i18n/mki18n.py Tue Aug 15 12:17:51 2017 +0300 @@ -141,7 +141,7 @@ # m a k e P O ( ) -- Build the Portable Object file for the application -- # ^^^^^^^^^^^^^^^ # -def makePO(applicationDirectoryPath, applicationDomain=None, verbose=0) : +def makePO(applicationDirectoryPath, applicationDomain=None, verbose=0): """Build the Portable Object Template file for the application. makePO builds the .pot file for the application stored inside @@ -204,7 +204,7 @@ if langCode == 'en': pass else: - langPOfileName = "%s_%s.po" % (applicationName , langCode) + langPOfileName = "%s_%s.po" % (applicationName, langCode) if os.path.exists(langPOfileName): cmd = 'msgmerge -s --no-wrap "%s" %s > "%s.new"' % (langPOfileName, fileout, langPOfileName) if verbose: print cmd @@ -212,7 +212,7 @@ os.chdir(currentDir) -def catPO(applicationDirectoryPath, listOf_extraPo, applicationDomain=None, targetDir=None, verbose=0) : +def catPO(applicationDirectoryPath, listOf_extraPo, applicationDomain=None, targetDir=None, verbose=0): """Concatenate one or several PO files with the application domain files. """ @@ -229,7 +229,7 @@ if langCode == 'en': pass else: - langPOfileName = "%s_%s.po" % (applicationName , langCode) + langPOfileName = "%s_%s.po" % (applicationName, langCode) if os.path.exists(langPOfileName): fileList = '' for fileName in listOf_extraPo: @@ -247,7 +247,7 @@ os.chdir(currentDir) -def makeMO(applicationDirectoryPath,targetDir='./locale',applicationDomain=None, verbose=0, forceEnglish=0) : +def makeMO(applicationDirectoryPath,targetDir='./locale',applicationDomain=None, verbose=0, forceEnglish=0): """Compile the Portable Object files into the Machine Object stored in the right location. makeMO converts all translated language-specific PO files located inside @@ -282,7 +282,7 @@ if (langCode == 'en') and (forceEnglish==0): pass else: - langPOfileName = "%s_%s.po" % (applicationName , langCode) + langPOfileName = "%s_%s.po" % (applicationName, langCode) if os.path.exists(langPOfileName): mo_targetDir = "%s/%s/LC_MESSAGES" % (targetDir,langCode) if not os.path.exists(mo_targetDir): @@ -293,7 +293,7 @@ os.chdir(currentDir) -def printUsage(errorMsg=None) : +def printUsage(errorMsg=None): """Displays how to use this script from the command line.""" print """ ################################################################################## @@ -330,7 +330,7 @@ print "\n ERROR: %s" % errorMsg -def fileBaseOf(filename,withPath=0) : +def fileBaseOf(filename,withPath=0): """fileBaseOf(filename,withPath) ---> string Return base name of filename. The returned string never includes the extension. @@ -369,7 +369,7 @@ return os.path.basename(filename) -def mkdir(directory) : +def mkdir(directory): """Create a directory (and possibly the entire tree). The os.mkdir() will fail to create a directory if one of the @@ -408,7 +408,7 @@ theDir += '/' -def unixpath(thePath) : +def unixpath(thePath): r"""Return a path name that contains Unix separator. [Example] diff -r d2e979738700 -r ec153828ded2 plcopen/definitions.py --- a/plcopen/definitions.py Mon Aug 14 23:38:28 2017 +0300 +++ b/plcopen/definitions.py Tue Aug 15 12:17:51 2017 +0300 @@ -35,11 +35,11 @@ LANGUAGES = ["IL","ST","FBD","LD","SFC"] -LOCATIONDATATYPES = {"X" : ["BOOL"], - "B" : ["SINT", "USINT", "BYTE", "STRING"], - "W" : ["INT", "UINT", "WORD", "WSTRING"], - "D" : ["DINT", "UDINT", "REAL", "DWORD"], - "L" : ["LINT", "ULINT", "LREAL", "LWORD"]} +LOCATIONDATATYPES = {"X": ["BOOL"], + "B": ["SINT", "USINT", "BYTE", "STRING"], + "W": ["INT", "UINT", "WORD", "WSTRING"], + "D": ["DINT", "UDINT", "REAL", "DWORD"], + "L": ["LINT", "ULINT", "LREAL", "LWORD"]} #------------------------------------------------------------------------------- # Function Block Types definitions diff -r d2e979738700 -r ec153828ded2 plcopen/plcopen.py --- a/plcopen/plcopen.py Mon Aug 14 23:38:28 2017 +0300 +++ b/plcopen/plcopen.py Tue Aug 15 12:17:51 2017 +0300 @@ -34,14 +34,21 @@ """ Dictionary that makes the relation between var names in plcopen and displayed values """ -VarTypes = {"Local" : "localVars", "Temp" : "tempVars", "Input" : "inputVars", - "Output" : "outputVars", "InOut" : "inOutVars", "External" : "externalVars", - "Global" : "globalVars", "Access" : "accessVars"} +VarTypes = { + "Local": "localVars", + "Temp": "tempVars", + "Input": "inputVars", + "Output": "outputVars", + "InOut": "inOutVars", + "External": "externalVars", + "Global": "globalVars", + "Access": "accessVars" +} searchResultVarTypes = { - "inputVars": "var_input", + "inputVars": "var_input", "outputVars": "var_output", - "inOutVars": "var_inout" + "inOutVars": "var_inout" } """ @@ -853,7 +860,7 @@ # Array derived directly from an elementary type else: basetype_name = base_type_name - return "ARRAY [%s] OF %s" % (",".join(map(lambda x : "%s..%s" % (x.getlower(), x.getupper()), vartype_content.getdimension())), basetype_name) + return "ARRAY [%s] OF %s" % (",".join(map(lambda x: "%s..%s" % (x.getlower(), x.getupper()), vartype_content.getdimension())), basetype_name) # Variable type is an elementary type return vartype_content_name setattr(cls, "gettypeAsText", gettypeAsText) @@ -1079,12 +1086,12 @@ "ppx:interface/*[self::ppx:outputVars or self::ppx:inOutVars]/ppx:variable") def getblockInfos(self): block_infos = { - "name" : self.getname(), - "type" : self.getpouType(), - "extensible" : False, - "inputs" : [], - "outputs" : [], - "comment" : self.getdescription()} + "name": self.getname(), + "type": self.getpouType(), + "extensible": False, + "inputs": [], + "outputs": [], + "comment": self.getdescription()} if self.interface is not None: return_type = self.interface.getreturnType() if return_type is not None: @@ -2075,7 +2082,7 @@ def getconditionContent(self): if self.condition is not None: content = self.condition.getcontent() - values = {"type" : content.getLocalTag()} + values = {"type": content.getLocalTag()} if values["type"] == "reference": values["value"] = content.getname() elif values["type"] == "inline": diff -r d2e979738700 -r ec153828ded2 plcopen/structures.py --- a/plcopen/structures.py Mon Aug 14 23:38:28 2017 +0300 +++ b/plcopen/structures.py Tue Aug 15 12:17:51 2017 +0300 @@ -70,9 +70,9 @@ - The default modifier which can be "none", "negated", "rising" or "falling" """ -StdBlckLibs = {libname : LoadProject(tc6fname)[0] +StdBlckLibs = {libname: LoadProject(tc6fname)[0] for libname, tc6fname in StdTC6Libs} -StdBlckLst = [{"name" : libname, "list": +StdBlckLst = [{"name": libname, "list": [GetBlockInfos(pous) for pous in lib.getpous()]} for libname, lib in StdBlckLibs.iteritems()] @@ -176,8 +176,8 @@ Current_section = None translate = { - "extensible" : lambda x: {"yes":True, "no":False}[x], - "inputs" : lambda x:csv_input_translate(x,variables,baseinputnumber), + "extensible": lambda x: {"yes":True, "no":False}[x], + "inputs": lambda x:csv_input_translate(x,variables,baseinputnumber), "outputs":lambda x:[("OUT",x,"none")]} for fields in table: @@ -189,7 +189,7 @@ section_name = words[1] else: section_name = fields[0] - Current_section = {"name" : section_name, "list" : []} + Current_section = {"name": section_name, "list": []} Standard_Functions_Decl.append(Current_section) Function_decl_list = [] if Current_section: @@ -201,7 +201,7 @@ Function_decl[param] = translate[param](value) Function_decl["type"] = "function" - if Function_decl["name"].startswith('*') or Function_decl["name"].endswith('*') : + if Function_decl["name"].startswith('*') or Function_decl["name"].endswith('*'): input_ovrloading_types = GetSubTypes(Function_decl["inputs"][0][1]) output_types = GetSubTypes(Function_decl["outputs"][0][1]) else: @@ -230,7 +230,7 @@ for outype in output_types: if outype != None: decl_tpl = Function_decl["outputs"][0] - Function_decl["outputs"] = [ (decl_tpl[0] , outype, decl_tpl[2])] + Function_decl["outputs"] = [ (decl_tpl[0], outype, decl_tpl[2])] if funcdeclname_orig.endswith('*'): funcdeclout = funcdeclin + '_' + outype else: @@ -244,11 +244,11 @@ store = True for (InTypes, OutTypes) in ANY_TO_ANY_FILTERS.get(filter_name,[]): outs = reduce(lambda a,b: a or b, - map(lambda testtype : IsOfType( + map(lambda testtype: IsOfType( Function_decl["outputs"][0][1], testtype), OutTypes)) inps = reduce(lambda a,b: a or b, - map(lambda testtype : IsOfType( + map(lambda testtype: IsOfType( Function_decl["inputs"][0][1], testtype), InTypes)) if inps and outs and Function_decl["outputs"][0][1] != Function_decl["inputs"][0][1]: @@ -256,7 +256,7 @@ break else: store = False - if store : + if store: # create the copy of decl dict to be appended to section Function_decl_copy = Function_decl.copy() Current_section["list"].append(Function_decl_copy) diff -r d2e979738700 -r ec153828ded2 py_ext/PythonFileCTNMixin.py --- a/py_ext/PythonFileCTNMixin.py Mon Aug 14 23:38:28 2017 +0300 +++ b/py_ext/PythonFileCTNMixin.py Tue Aug 15 12:17:51 2017 +0300 @@ -99,19 +99,19 @@ configname = self.GetCTRoot().GetProjectConfigNames()[0] pyextname = self.CTNName() - varinfos = map(lambda variable : { + varinfos = map(lambda variable: { "name": variable.getname(), - "desc" : repr(variable.getdesc()), - "onchangecode" : '"'+variable.getonchange()+\ + "desc": repr(variable.getdesc()), + "onchangecode": '"'+variable.getonchange()+\ "('"+variable.getname()+"')\"" \ if variable.getonchange() else '""', - "onchange" : repr(variable.getonchange()) \ + "onchange": repr(variable.getonchange()) \ if variable.getonchange() else None, - "opts" : repr(variable.getopts()), - "configname" : configname.upper(), - "uppername" : variable.getname().upper(), - "IECtype" : variable.gettype(), - "pyextname" :pyextname}, + "opts": repr(variable.getopts()), + "configname": configname.upper(), + "uppername": variable.getname().upper(), + "IECtype": variable.gettype(), + "pyextname": pyextname}, self.CodeFile.variables.variable) # python side PLC global variables access stub globalstubs = "\n".join(["""\ diff -r d2e979738700 -r ec153828ded2 runtime/PLCObject.py --- a/runtime/PLCObject.py Mon Aug 14 23:38:28 2017 +0300 +++ b/runtime/PLCObject.py Tue Aug 15 12:17:51 2017 +0300 @@ -110,7 +110,7 @@ self._ResetLogCount() def GetLogCount(self, level): - if self._GetLogCount is not None : + if self._GetLogCount is not None: return int(self._GetLogCount(level)) elif self._loading_error is not None and level==0: return 1 @@ -151,7 +151,7 @@ self.PLClibraryHandle = ctypes.CDLL(self.CurrentPLCFilename, handle=self._PLClibraryHandle) self.PLC_ID = ctypes.c_char_p.in_dll(self.PLClibraryHandle, "PLC_ID") - if len(md5) == 32 : + if len(md5) == 32: self.PLC_ID.value = md5 self._startPLC = self.PLClibraryHandle.startPLC @@ -280,7 +280,7 @@ class PLCSafeGlobals: def __getattr__(_self, name): - try : + try: t = self.python_runtime_vars["_"+name+"_ctype"] except KeyError: raise KeyError("Try to get unknown shared global variable : %s" % name) @@ -288,7 +288,7 @@ r = self.python_runtime_vars["_PySafeGetPLCGlob_"+name](ctypes.byref(v)) return self.python_runtime_vars["_"+name+"_unpack"](v) def __setattr__(_self, name, value): - try : + try: t = self.python_runtime_vars["_"+name+"_ctype"] except KeyError: raise KeyError("Try to set unknown shared global variable : %s" % name) @@ -296,13 +296,13 @@ self.python_runtime_vars["_PySafeSetPLCGlob_"+name](ctypes.byref(v)) self.python_runtime_vars.update({ - "PLCGlobals" : PLCSafeGlobals(), - "WorkingDir" : self.workingdir, - "PLCObject" : self, - "PLCBinary" : self.PLClibraryHandle, - "PLCGlobalsDesc" : []}) - - for methodname in MethodNames : + "PLCGlobals": PLCSafeGlobals(), + "WorkingDir": self.workingdir, + "PLCObject": self, + "PLCBinary": self.PLClibraryHandle, + "PLCGlobalsDesc": []}) + + for methodname in MethodNames: self.python_runtime_vars["_runtime_%s" % methodname] = [] try: @@ -341,7 +341,7 @@ # print " -> ", cmd, blkid if cmd is None: break - try : + try: self.python_runtime_vars["FBID"]=FBID ccmd,AST =compile_cache.get(FBID, (None,None)) if ccmd is None or ccmd!=cmd: @@ -386,7 +386,7 @@ self.PLCStatus = "Stopped" self.StatusChange() self.PythonRuntimeCall("stop") - if self.TraceThread is not None : + if self.TraceThread is not None: self.TraceWakeup.set() self.TraceThread.join() self.TraceThread = None @@ -495,7 +495,7 @@ def _TracesPush(self, trace): self.TraceLock.acquire() lT = len(self.Traces) - if lT != 0 and lT * len(self.Traces[0]) > 1024 * 1024 : + if lT != 0 and lT * len(self.Traces[0]) > 1024 * 1024: self.Traces.pop(0) self.Traces.append(trace) self.TraceLock.release() @@ -536,7 +536,7 @@ """ Return a list of traces, corresponding to the list of required idx """ - while self.PLCStatus == "Started" : + while self.PLCStatus == "Started": tick = ctypes.c_uint32() size = ctypes.c_uint32() buff = ctypes.c_void_p() diff -r d2e979738700 -r ec153828ded2 svgui/pyjs/build.py --- a/svgui/pyjs/build.py Mon Aug 14 23:38:28 2017 +0300 +++ b/svgui/pyjs/build.py Tue Aug 15 12:17:51 2017 +0300 @@ -147,10 +147,10 @@ return 0 if os.path.exists ( - os.path.join ( dest_path, mod_name + '.css' ) ) : + os.path.join ( dest_path, mod_name + '.css' ) ): css = "" elif os.path.exists ( - os.path.join ( dest_path, 'pyjamas_default.css' ) ) : + os.path.join ( dest_path, 'pyjamas_default.css' ) ): css = "" else: diff -r d2e979738700 -r ec153828ded2 svgui/svgui.py --- a/svgui/svgui.py Mon Aug 14 23:38:28 2017 +0300 +++ b/svgui/svgui.py Tue Aug 15 12:17:51 2017 +0300 @@ -44,14 +44,18 @@ class SVGUI(PythonFileCTNMixin): ConfNodeMethods = [ - {"bitmap" : "ImportSVG", - "name" : _("Import SVG"), - "tooltip" : _("Import SVG"), - "method" : "_ImportSVG"}, - {"bitmap" : "ImportSVG", # should be something different - "name" : _("Inkscape"), - "tooltip" : _("Create HMI"), - "method" : "_StartInkscape"}, + { + "bitmap": "ImportSVG", + "name": _("Import SVG"), + "tooltip": _("Import SVG"), + "method": "_ImportSVG" + }, + { + "bitmap": "ImportSVG", # should be something different + "name": _("Inkscape"), + "tooltip": _("Create HMI"), + "method": "_StartInkscape" + }, ] def ConfNodePath(self): @@ -110,7 +114,7 @@ runtimefile_path = os.path.join(buildpath, "runtime_%s.py" % location_str) runtimefile = open(runtimefile_path, 'w') - runtimefile.write(svguiservercode % {"svgfile" : "gui.svg"}) + runtimefile.write(svguiservercode % {"svgfile": "gui.svg"}) runtimefile.write(""" def _runtime_%(location)s_start(): website.LoadHMI(%(svgui_class)s, %(jsmodules)s) @@ -120,7 +124,7 @@ """ % {"location": location_str, "svgui_class": "SVGUI_HMI", - "jsmodules" : str(jsmodules), + "jsmodules": str(jsmodules), }) runtimefile.close() diff -r d2e979738700 -r ec153828ded2 targets/__init__.py --- a/targets/__init__.py Mon Aug 14 23:38:28 2017 +0300 +++ b/targets/__init__.py Tue Aug 15 12:17:51 2017 +0300 @@ -66,7 +66,7 @@ targetchoices = "" # Get all xsd toolchains - for toolchainname,xsdfilename in toolchains.iteritems() : + for toolchainname,xsdfilename in toolchains.iteritems(): if path.isfile(xsdfilename): DictXSD_toolchain["toolchain_"+toolchainname] = \ open(xsdfilename).read() diff -r d2e979738700 -r ec153828ded2 targets/toolchain_gcc.py --- a/targets/toolchain_gcc.py Mon Aug 14 23:38:28 2017 +0300 +++ b/targets/toolchain_gcc.py Tue Aug 15 12:17:51 2017 +0300 @@ -164,7 +164,7 @@ relink = self.GetBinaryCode() is None for Location, CFilesAndCFLAGS, DoCalls in self.CTRInstance.LocationCFilesAndCFLAGS: if CFilesAndCFLAGS: - if Location : + if Location: self.CTRInstance.logger.write(".".join(map(str,Location))+" :\n") else: self.CTRInstance.logger.write(_("PLC :\n")) @@ -190,7 +190,7 @@ (self.compiler, CFile, objectfilename, Builder_CFLAGS, CFLAGS) ).spin() - if status : + if status: self.srcmd5.pop(bn) self.CTRInstance.logger.write_error(_("C compilation of %s failed.\n") % bn) return False @@ -222,7 +222,7 @@ ALLldflags) ).spin() - if status : + if status: return False else: diff -r d2e979738700 -r ec153828ded2 targets/toolchain_makefile.py --- a/targets/toolchain_makefile.py Mon Aug 14 23:38:28 2017 +0300 +++ b/targets/toolchain_makefile.py Tue Aug 15 12:17:51 2017 +0300 @@ -104,7 +104,7 @@ f.write(self.md5key) f.close() - if oldmd5 != self.md5key : + if oldmd5 != self.md5key: target = self.CTRInstance.GetTarget().getcontent() beremizcommand = {"src": ' '.join(srcfiles), "cflags": ' '.join(cflags), @@ -120,11 +120,11 @@ # Call Makefile to build PLC code and link it with target specific code status, result, err_result = ProcessLogger(self.CTRInstance.logger, command).spin() - if status : + if status: self.md5key = None self.CTRInstance.logger.write_error(_("C compilation failed.\n")) return False return True - else : + else: self.CTRInstance.logger.write(_("Source didn't change, no build.\n")) return True diff -r d2e979738700 -r ec153828ded2 targets/typemapping.py --- a/targets/typemapping.py Mon Aug 14 23:38:28 2017 +0300 +++ b/targets/typemapping.py Tue Aug 15 12:17:51 2017 +0300 @@ -55,31 +55,31 @@ lambda t,x:t(x.days * 24 * 3600 + x.seconds, x.microseconds*1000)) SameEndianessTypeTranslator = { - "BOOL" : _t(c_uint8, lambda x:x.value!=0), - "STEP" : _t(c_uint8), - "TRANSITION" : _t(c_uint8), - "ACTION" : _t(c_uint8), - "SINT" : _t(c_int8), - "USINT" : _t(c_uint8), - "BYTE" : _t(c_uint8), - "STRING" : (IEC_STRING, - lambda x:x.body[:x.len], - lambda t,x:t(len(x),x)), - "INT" : _t(c_int16), - "UINT" : _t(c_uint16), - "WORD" : _t(c_uint16), - "DINT" : _t(c_int32), - "UDINT" : _t(c_uint32), - "DWORD" : _t(c_uint32), - "LINT" : _t(c_int64), - "ULINT" : _t(c_uint64), - "LWORD" : _t(c_uint64), - "REAL" : _t(c_float), - "LREAL" : _t(c_double), - "TIME" : _ttime(), - "TOD" : _ttime(), - "DATE" : _ttime(), - "DT" : _ttime(), + "BOOL": _t(c_uint8, lambda x:x.value!=0), + "STEP": _t(c_uint8), + "TRANSITION": _t(c_uint8), + "ACTION": _t(c_uint8), + "SINT": _t(c_int8), + "USINT": _t(c_uint8), + "BYTE": _t(c_uint8), + "STRING": (IEC_STRING, + lambda x:x.body[:x.len], + lambda t,x:t(len(x),x)), + "INT": _t(c_int16), + "UINT": _t(c_uint16), + "WORD": _t(c_uint16), + "DINT": _t(c_int32), + "UDINT": _t(c_uint32), + "DWORD": _t(c_uint32), + "LINT": _t(c_int64), + "ULINT": _t(c_uint64), + "LWORD": _t(c_uint64), + "REAL": _t(c_float), + "LREAL": _t(c_double), + "TIME": _ttime(), + "TOD": _ttime(), + "DATE": _ttime(), + "DT": _ttime(), } SwapedEndianessTypeTranslator = { diff -r d2e979738700 -r ec153828ded2 util/ProcessLogger.py --- a/util/ProcessLogger.py Mon Aug 14 23:38:28 2017 +0300 +++ b/util/ProcessLogger.py Tue Aug 15 12:17:51 2017 +0300 @@ -50,17 +50,17 @@ def run(self): outchunk = None self.retval = None - while self.retval is None and not self.killed : + while self.retval is None and not self.killed: if self.endcallback: self.retval = self.Proc.poll() else: self.retval = self.Proc.returncode outchunk = self.fd.readline() - if self.callback : self.callback(outchunk) - while outchunk != '' and not self.killed : + if self.callback: self.callback(outchunk) + while outchunk != '' and not self.killed: outchunk = self.fd.readline() - if self.callback : self.callback(outchunk) + if self.callback: self.callback(outchunk) if self.endcallback: try: err = self.Proc.wait() diff -r d2e979738700 -r ec153828ded2 util/Zeroconf.py --- a/util/Zeroconf.py Mon Aug 14 23:38:28 2017 +0300 +++ b/util/Zeroconf.py Tue Aug 15 12:17:51 2017 +0300 @@ -154,32 +154,32 @@ # Mapping constants to names -_CLASSES = { _CLASS_IN : "in", - _CLASS_CS : "cs", - _CLASS_CH : "ch", - _CLASS_HS : "hs", - _CLASS_NONE : "none", - _CLASS_ANY : "any" } - -_TYPES = { _TYPE_A : "a", - _TYPE_NS : "ns", - _TYPE_MD : "md", - _TYPE_MF : "mf", - _TYPE_CNAME : "cname", - _TYPE_SOA : "soa", - _TYPE_MB : "mb", - _TYPE_MG : "mg", - _TYPE_MR : "mr", - _TYPE_NULL : "null", - _TYPE_WKS : "wks", - _TYPE_PTR : "ptr", - _TYPE_HINFO : "hinfo", - _TYPE_MINFO : "minfo", - _TYPE_MX : "mx", - _TYPE_TXT : "txt", - _TYPE_AAAA : "quada", - _TYPE_SRV : "srv", - _TYPE_ANY : "any" } +_CLASSES = { _CLASS_IN: "in", + _CLASS_CS: "cs", + _CLASS_CH: "ch", + _CLASS_HS: "hs", + _CLASS_NONE: "none", + _CLASS_ANY: "any" } + +_TYPES = { _TYPE_A: "a", + _TYPE_NS: "ns", + _TYPE_MD: "md", + _TYPE_MF: "mf", + _TYPE_CNAME: "cname", + _TYPE_SOA: "soa", + _TYPE_MB: "mb", + _TYPE_MG: "mg", + _TYPE_MR: "mr", + _TYPE_NULL: "null", + _TYPE_WKS: "wks", + _TYPE_PTR: "ptr", + _TYPE_HINFO: "hinfo", + _TYPE_MINFO: "minfo", + _TYPE_MX: "mx", + _TYPE_TXT: "txt", + _TYPE_AAAA: "quada", + _TYPE_SRV: "srv", + _TYPE_ANY: "any" } # utility functions diff -r d2e979738700 -r ec153828ded2 wxglade_hmi/wxglade_hmi.py --- a/wxglade_hmi/wxglade_hmi.py Mon Aug 14 23:38:28 2017 +0300 +++ b/wxglade_hmi/wxglade_hmi.py Tue Aug 15 12:17:51 2017 +0300 @@ -36,10 +36,12 @@ class WxGladeHMI(PythonFileCTNMixin): ConfNodeMethods = [ - {"bitmap" : "editWXGLADE", - "name" : _("WXGLADE GUI"), - "tooltip" : _("Edit a WxWidgets GUI with WXGlade"), - "method" : "_editWXGLADE"}, + { + "bitmap": "editWXGLADE", + "name": _("WXGLADE GUI"), + "tooltip": _("Edit a WxWidgets GUI with WXGlade"), + "method": "_editWXGLADE" + }, ] def GetIconName(self): @@ -97,9 +99,9 @@ for node in wxgtree.childNodes[1].childNodes: if node.nodeType == wxgtree.ELEMENT_NODE: hmi_frames.append({ - "name" : node.getAttribute("name"), - "class" : node.getAttribute("class"), - "handlers" : [ + "name": node.getAttribute("name"), + "class": node.getAttribute("class"), + "handlers": [ hnode.firstChild.data for hnode in node.getElementsByTagName("handler")]}) diff -r d2e979738700 -r ec153828ded2 xmlclass/xmlclass.py --- a/xmlclass/xmlclass.py Mon Aug 14 23:38:28 2017 +0300 +++ b/xmlclass/xmlclass.py Tue Aug 15 12:17:51 2017 +0300 @@ -84,7 +84,7 @@ self.__offset = timedelta(minutes = 0) self.__name = "UTC" else: - sign = {"-" : -1, "+" : 1}[offset[0]] + sign = {"-": -1, "+": 1}[offset[0]] hours, minutes = [int(val) for val in offset[1:].split(":")] self.__offset = timedelta(minutes=sign * (hours * 60 + minutes)) self.__name = "" @@ -1399,7 +1399,7 @@ if facets.has_key("enumeration") and facets["enumeration"][0] is not None: return facets["enumeration"][0] elif facets.has_key("maxInclusive"): - limits = {"max" : None, "min" : None} + limits = {"max": None, "min": None} if facets["maxInclusive"][0] is not None: limits["max"] = facets["maxInclusive"][0] elif facets["maxExclusive"][0] is not None: @@ -1420,9 +1420,9 @@ attr_list.extend(classinfos["base"].getElementAttributes(self)) for attr in classinfos["attributes"]: if attr["use"] != "prohibited": - attr_params = {"name" : attr["name"], "use" : attr["use"], - "type" : gettypeinfos(attr["attr_type"]["basename"], attr["attr_type"]["facets"]), - "value" : getattr(self, attr["name"], "")} + attr_params = {"name": attr["name"], "use": attr["use"], + "type": gettypeinfos(attr["attr_type"]["basename"], attr["attr_type"]["facets"]), + "value": getattr(self, attr["name"], "")} attr_list.append(attr_params) return attr_list return getElementAttributes diff -r d2e979738700 -r ec153828ded2 xmlclass/xsdschema.py --- a/xmlclass/xsdschema.py Mon Aug 14 23:38:28 2017 +0300 +++ b/xmlclass/xsdschema.py Tue Aug 15 12:17:51 2017 +0300 @@ -668,7 +668,7 @@ # Attribute elements def ReduceAnyAttribute(factory, attributes, elements): - return {"type" : "anyAttribute"} + return {"type": "anyAttribute"} def ReduceAttribute(factory, attributes, elements): @@ -1313,7 +1313,7 @@ "reduce": ReduceComplexType }, - "documentation": {"struct" : """ + "documentation": {"struct": """ @@ -1744,7 +1744,7 @@ "reduce": ReduceSimpleContent }, - "simpleType": {"struct" : """ + "simpleType": {"struct": """