# HG changeset patch # User Andrey Skvortsov # Date 1502976392 -10800 # Node ID ccf59c1f0b4561d55a4462dce061b631e9d6ef0c # Parent d5df428640ff530902dda821beb258b089648517 clean-up: fix PEP8 W602 deprecated form of raising exception diff -r d5df428640ff -r ccf59c1f0b45 ConfigTreeNode.py --- a/ConfigTreeNode.py Thu Aug 17 15:43:25 2017 +0300 +++ b/ConfigTreeNode.py Thu Aug 17 16:26:32 2017 +0300 @@ -529,7 +529,8 @@ try: CTNClass, CTNHelp = CTNChildrenTypes[CTNType] except KeyError: - raise Exception, _("Cannot create child {a1} of type {a2} ").format(a1=CTNName, a2=CTNType) + raise Exception(_("Cannot create child {a1} of type {a2} "). + format(a1=CTNName, a2=CTNType)) # if CTNClass is a class factory, call it. (prevent unneeded imports) if type(CTNClass) == types.FunctionType: @@ -539,8 +540,9 @@ ChildrenWithSameClass = self.Children.setdefault(CTNType, list()) # Check count if getattr(CTNClass, "CTNMaxCount", None) and len(ChildrenWithSameClass) >= CTNClass.CTNMaxCount: - msg = _("Max count ({a1}) reached for this confnode of type {a2} ").format(a1=CTNClass.CTNMaxCount, a2=CTNType) - raise Exception, msg + raise Exception( + _("Max count ({a1}) reached for this confnode of type {a2} "). + format(a1=CTNClass.CTNMaxCount, a2=CTNType)) # create the final class, derived of provided confnode and template class FinalCTNClass(CTNClass, ConfigTreeNode): @@ -566,9 +568,9 @@ _self.LoadXMLParams(NewCTNName) # Basic check. Better to fail immediately. if (_self.BaseParams.getName() != NewCTNName): - msg = _("Project tree layout do not match confnode.xml {a1}!={a2} ").\ - format(a1=NewCTNName, a2=_self.BaseParams.getName()) - raise Exception, msg + raise Exception( + _("Project tree layout do not match confnode.xml {a1}!={a2} "). + format(a1=NewCTNName, a2=_self.BaseParams.getName())) # Now, self.CTNPath() should be OK diff -r d5df428640ff -r ccf59c1f0b45 IDEFrame.py --- a/IDEFrame.py Thu Aug 17 15:43:25 2017 +0300 +++ b/IDEFrame.py Thu Aug 17 16:26:32 2017 +0300 @@ -296,7 +296,7 @@ split = None for idx, tab in enumerate(tabs): if len(tab["pages"]) == 0: - raise ValueError, "Not possible" + raise ValueError("Not possible") if tab["size"][0] == rect.width: if tab["pos"][1] == rect.y: split = (wx.TOP, float(tab["size"][1]) / float(rect.height)) @@ -820,7 +820,7 @@ if isinstance(tabs, ListType): if len(tabs) == 0: return - raise ValueError, "Not supported" + raise ValueError("Not supported") if "split" in tabs: self.LoadTabLayout(notebook, tabs["others"]) diff -r d5df428640ff -r ccf59c1f0b45 PLCGenerator.py --- a/PLCGenerator.py Thu Aug 17 15:43:25 2017 +0300 +++ b/PLCGenerator.py Thu Aug 17 16:26:32 2017 +0300 @@ -254,7 +254,7 @@ program = pou_program.GenerateProgram(pou) self.Program += program else: - raise PLCGenException, _("Undefined pou type \"%s\"") % pou_type + raise PLCGenException(_("Undefined pou type \"%s\"") % pou_type) # Generate a POU defined and used in text def GeneratePouProgramInText(self, text): @@ -397,9 +397,9 @@ # Single argument if exists if single is not None: if len(single) == 0: - msg = _("Source signal has to be defined for single task '{a1}' in resource '{a2}.{a3}'.").\ - format(a1=task.getname(), a2=config_name, a3=resource.getname()) - raise PLCGenException, msg + raise PLCGenException( + _("Source signal has to be defined for single task '{a1}' in resource '{a2}.{a3}'."). + format(a1=task.getname(), a2=config_name, a3=resource.getname())) if single[0] == '[' and single[-1] == ']': SNGLKW = "MULTI" @@ -775,7 +775,9 @@ self.ConnectionTypes[content["value"]] = "BOOL" connections = content["value"].getconnections() if not connections: - raise PLCGenException, _("SFC transition in POU \"%s\" must be connected.") % self.Name + raise PLCGenException( + _("SFC transition in POU \"%s\" must be connected.") % self.Name) + for link in connections: connected = self.GetLinkedConnector(link, body) if connected is not None and not connected in self.ConnectionTypes: @@ -788,8 +790,9 @@ for element in body.getcontentInstances(): if isinstance(element, ConnectorClass) and element.getname() == name: if connector is not None: - msg = _("More than one connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1=name, a2=self.Name) - raise PLCGenException, msg + raise PLCGenException( + _("More than one connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU"). + format(a1=name, a2=self.Name)) connector = element if connector is not None: undefined = [instance.connectionPointOut, connector.connectionPointIn] @@ -808,8 +811,10 @@ for connection in related: self.ConnectionTypes[connection] = var_type else: - msg = _("No connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1=name, a2=self.Name) - raise PLCGenException, msg + raise PLCGenException( + _("No connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU"). + format(a1=name, a2=self.Name)) + elif isinstance(instance, BlockClass): block_infos = self.GetBlockType(instance.gettypeName(), "undefined") if block_infos is not None: @@ -831,7 +836,8 @@ if block_infos is not None: self.ComputeBlockInputTypes(instance, block_infos, body) else: - raise PLCGenException, _("No informations found for \"%s\" block") % (instance.gettypeName()) + raise PLCGenException( + _("No informations found for \"%s\" block") % (instance.gettypeName())) if body_type == "SFC": previous_tagname = self.TagName for action in pou.getactionList(): @@ -963,11 +969,13 @@ if block_infos is None: block_infos = self.GetBlockType(block_type) if block_infos is None: - raise PLCGenException, _("Undefined block type \"{a1}\" in \"{a2}\" POU").format(a1=block_type, a2=self.Name) + raise PLCGenException( + _("Undefined block type \"{a1}\" in \"{a2}\" POU"). + format(a1=block_type, a2=self.Name)) try: self.GenerateBlock(instance, block_infos, body, None) except ValueError, e: - raise PLCGenException, e.message + raise PLCGenException(e.message) elif isinstance(instance, ConnectorClass): connector = instance.getname() if self.ComputedConnectors.get(connector, None): @@ -1196,9 +1204,9 @@ blockname = "{a1}({a2})".format(a1=name, a2=type) else: blockname = type - msg = _("No output {a1} variable found in block {a2} in POU {a3}. Connection must be broken").\ - format(a1=output_parameter, a2=blockname, a3=self.Name) - raise ValueError, msg + raise ValueError( + _("No output {a1} variable found in block {a2} in POU {a3}. Connection must be broken"). + format(a1=output_parameter, a2=blockname, a3=self.Name)) def GeneratePaths(self, connections, body, order=False, to_inout=False): paths = [] @@ -1216,12 +1224,13 @@ if block_infos is None: block_infos = self.GetBlockType(block_type) if block_infos is None: - msg = _("Undefined block type \"{a1}\" in \"{a2}\" POU").format(a1=block_type, a2=self.Name) - raise PLCGenException, msg + raise PLCGenException( + _("Undefined block type \"{a1}\" in \"{a2}\" POU"). + format(a1=block_type, a2=self.Name)) try: paths.append(str(self.GenerateBlock(next, block_infos, body, connection, order, to_inout))) except ValueError, e: - raise PLCGenException, e.message + raise PLCGenException(e.message) elif isinstance(next, ContinuationClass): name = next.getname() computed_value = self.ComputedConnectors.get(name, None) @@ -1232,8 +1241,9 @@ for instance in body.getcontentInstances(): if isinstance(instance, ConnectorClass) and instance.getname() == name: if connector is not None: - msg = _("More than one connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1=name, a2=self.Name) - raise PLCGenException, msg + raise PLCGenException( + _("More than one connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU"). + format(a1=name, a2=self.Name)) connector = instance if connector is not None: connections = connector.connectionPointIn.getconnections() @@ -1243,8 +1253,9 @@ self.ComputedConnectors[name] = expression paths.append(str(expression)) else: - msg = _("No connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU").format(a1=name, a2=self.Name) - raise PLCGenException, msg + raise PLCGenException( + _("No connector found corresponding to \"{a1}\" continuation in \"{a2}\" POU"). + format(a1=name, a2=self.Name)) elif isinstance(next, ContactClass): contact_info = (self.TagName, "contact", next.getlocalId()) variable = str(self.ExtractModifier(next, [(next.getvariable(), contact_info + ("reference",))], contact_info)) @@ -1394,8 +1405,10 @@ jump_target = jump.gettargetName() if not pou.hasstep(jump_target): pname = pou.getname() - msg = _("SFC jump in pou \"{a1}\" refers to non-existent SFC step \"{a2}\"").format(a1=pname, a2=jump_target) - raise PLCGenException, msg + raise PLCGenException( + _("SFC jump in pou \"{a1}\" refers to non-existent SFC step \"{a2}\""). + format(a1=pname, a2=jump_target)) + if jump.connectionPointIn is not None: instances = [] connections = jump.connectionPointIn.getconnections() @@ -1520,7 +1533,9 @@ self.SFCComputedBlocks += self.Program self.Program = [] if not "content" in transition_infos: - raise PLCGenException, _("Transition \"%s\" body must contain an output variable or coil referring to its name") % transitionValues["value"] + raise PLCGenException( + _("Transition \"%s\" body must contain an output variable or coil referring to its name") + % transitionValues["value"]) self.TagName = previous_tagname elif transitionValues["type"] == "connection": body = pou.getbody() @@ -1600,9 +1615,9 @@ elif len(transition_infos["from"]) == 1: self.Program += transition_infos["from"][0] else: - msg = _("Transition with content \"{a1}\" not connected to a previous step in \"{a2}\" POU").\ - format(a1=transition_infos["content"], a2=self.Name) - raise PLCGenException, msg + raise PLCGenException( + _("Transition with content \"{a1}\" not connected to a previous step in \"{a2}\" POU"). + format(a1=transition_infos["content"], a2=self.Name)) self.Program += [(" TO ", ())] if len(transition_infos["to"]) > 1: self.Program += [("(", ())] @@ -1611,9 +1626,9 @@ elif len(transition_infos["to"]) == 1: self.Program += transition_infos["to"][0] else: - msg = _("Transition with content \"{a1}\" not connected to a next step in \"{a2}\" POU").\ - format(a1=transition_infos["content"], a2=self.Name) - raise PLCGenException, msg + raise PLCGenException( + _("Transition with content \"{a1}\" not connected to a next step in \"{a2}\" POU"). + format(a1=transition_infos["content"], a2=self.Name)) self.Program += transition_infos["content"] self.Program += [("%sEND_TRANSITION\n\n" % self.CurrentIndent, ())] for [(step_name, step_infos)] in transition_infos["to"]: @@ -1631,9 +1646,9 @@ (self.ReturnType, (self.TagName, "return"))] program += [("\n", ())] if len(self.Interface) == 0: - raise PLCGenException, _("No variable defined in \"%s\" POU") % self.Name + raise PLCGenException(_("No variable defined in \"%s\" POU") % self.Name) if len(self.Program) == 0: - raise PLCGenException, _("No body defined in \"%s\" POU") % self.Name + raise PLCGenException(_("No body defined in \"%s\" POU") % self.Name) var_number = 0 for list_type, option, located, variables in self.Interface: variable_type = errorVarTypes.get(list_type, "var_local") diff -r d5df428640ff -r ccf59c1f0b45 canfestival/canfestival.py --- a/canfestival/canfestival.py Thu Aug 17 15:43:25 2017 +0300 +++ b/canfestival/canfestival.py Thu Aug 17 16:26:32 2017 +0300 @@ -231,10 +231,10 @@ pointers = config_utils.LocalODPointers(locations, current_location, slave) res = gen_cfile.GenerateFile(Gen_OD_path, slave, pointers) if res: - raise Exception, res + raise Exception(res) res = eds_utils.GenerateEDSFile(os.path.join(buildpath, "Slave_%s.eds" % prefix), slave) if res: - raise Exception, res + raise Exception(res) return [(Gen_OD_path, local_canfestival_config.getCFLAGS(CanFestivalPath))], "", False def LoadPrevious(self): @@ -448,11 +448,11 @@ try: master, pointers = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs(), "OD_%s" % prefix) except config_utils.PDOmappingException, e: - raise Exception, e.message + raise Exception(e.message) # Do generate C file. res = gen_cfile.GenerateFile(Gen_OD_path, master, pointers) if res: - raise Exception, res + raise Exception(res) file = open(os.path.join(buildpath, "MasterGenerated.od"), "w") dump(master, file) diff -r d5df428640ff -r ccf59c1f0b45 canfestival/config_utils.py --- a/canfestival/config_utils.py Thu Aug 17 15:43:25 2017 +0300 +++ b/canfestival/config_utils.py Thu Aug 17 16:26:32 2017 +0300 @@ -348,13 +348,13 @@ name = location["NAME"] if name in self.IECLocations: if self.IECLocations[name]["type"] != COlocationtype: - raise PDOmappingException, _("Type conflict for location \"%s\"") % name + raise PDOmappingException(_("Type conflict for location \"%s\"") % name) else: # Get only the part of the location that concern this node loc = location["LOC"][len(current_location):] # loc correspond to (ID, INDEX, SUBINDEX [,BIT]) if len(loc) not in (2, 3, 4): - raise PDOmappingException, _("Bad location size : %s") % str(loc) + raise PDOmappingException(_("Bad location size : %s") % str(loc)) elif len(loc) == 2: continue @@ -367,7 +367,9 @@ # Check Id is in slave node list if nodeid not in self.NodeList.SlaveNodes.keys(): - raise PDOmappingException, _("Non existing node ID : {a1} (variable {a2})").format(a1=nodeid, a2=name) + raise PDOmappingException( + _("Non existing node ID : {a1} (variable {a2})"). + format(a1=nodeid, a2=name)) # Get the model for this node (made from EDS) node = self.NodeList.SlaveNodes[nodeid]["Node"] @@ -376,7 +378,7 @@ if not node.IsEntry(index, subindex): msg = _("No such index/subindex ({a1},{a2}) in ID : {a3} (variable {a4})").\ format(a1="%x" % index, a2="%x" % subindex, a3=nodeid, a4=name) - raise PDOmappingException, msg + raise PDOmappingException(msg) # Get the entry info subentry_infos = node.GetSubentryInfos(index, subindex) @@ -386,15 +388,19 @@ if sizelocation == "X" and len(loc) > 3: numbit = loc[3] elif sizelocation != "X" and len(loc) > 3: - msg = _("Cannot set bit offset for non bool '{a1}' variable (ID:{a2},Idx:{a3},sIdx:{a4}))").\ - format(a1=name, a2=nodeid, a3="%x" % index, a4="%x" % subindex) - raise PDOmappingException, msg + raise PDOmappingException( + _("Cannot set bit offset for non bool '{a1}' variable (ID:{a2},Idx:{a3},sIdx:{a4}))"). + format(a1=name, a2=nodeid, a3="%x" % index, a4="%x" % subindex)) else: numbit = None 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) + raise PDOmappingException( + _("Invalid type \"{a1}\"-> {a2} != {a3} for location \"{a4}\""). + format(a1=location["IEC_TYPE"], + a2=COlocationtype, + a3=subentry_infos["type"], + a4=name)) typeinfos = node.GetEntryInfos(COlocationtype) self.IECLocations[name] = { @@ -408,8 +414,9 @@ "sizelocation": sizelocation } else: - raise PDOmappingException, _("Not PDO mappable variable : '{a1}' (ID:{a2},Idx:{a3},sIdx:{a4}))").\ - format(a1=name, a2=nodeid, a3="%x" % index, a4="%x" % subindex) + raise PDOmappingException( + _("Not PDO mappable variable : '{a1}' (ID:{a2},Idx:{a3},sIdx:{a4}))"). + format(a1=name, a2=nodeid, a3="%x" % index, a4="%x" % subindex)) #------------------------------------------------------------------------------- # Search for locations already mapped @@ -481,7 +488,8 @@ pdomapping = [] result = self.GetEmptyPDO(nodeid, pdotype) if result is None: - raise PDOmappingException, _("Unable to define PDO mapping for node %02x") % nodeid + raise PDOmappingException( + _("Unable to define PDO mapping for node %02x") % nodeid) pdoindex, pdocobid, pdonbparams = result for name, loc_infos in locations[pdotype]: pdosize += loc_infos["size"] @@ -495,7 +503,8 @@ pdomapping = [(name, loc_infos)] result = self.GetEmptyPDO(nodeid, pdotype, pdoindex + 1) if result is None: - raise PDOmappingException, _("Unable to define PDO mapping for node %02x") % nodeid + raise PDOmappingException( + _("Unable to define PDO mapping for node %02x") % nodeid) pdoindex, pdocobid, pdonbparams = result else: pdomapping.append((name, loc_infos)) @@ -645,13 +654,13 @@ name = location["NAME"] if name in IECLocations: if IECLocations[name] != COlocationtype: - raise PDOmappingException, _("Type conflict for location \"%s\"") % name + raise PDOmappingException(_("Type conflict for location \"%s\"") % name) else: # Get only the part of the location that concern this node loc = location["LOC"][len(current_location):] # loc correspond to (ID, INDEX, SUBINDEX [,BIT]) if len(loc) not in (2, 3, 4): - raise PDOmappingException, _("Bad location size : %s") % str(loc) + raise PDOmappingException(_("Bad location size : %s") % str(loc)) elif len(loc) != 2: continue @@ -660,14 +669,19 @@ # Extract and check index and subindex if not slave.IsEntry(index, subindex): - raise PDOmappingException, _("No such index/subindex ({a1},{a2}) (variable {a3})").\ - format(a1="%x" % index, a2="%x" % subindex, a3=name) + raise PDOmappingException( + _("No such index/subindex ({a1},{a2}) (variable {a3})"). + format(a1="%x" % index, a2="%x" % subindex, a3=name)) # Get the entry info 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) + raise PDOmappingException( + _("Invalid type \"{a1}\"-> {a2} != {a3} for location \"{a4}\""). + format(a1=location["IEC_TYPE"], + a2=COlocationtype, + a3=subentry_infos["type"], + a4=name)) IECLocations[name] = COlocationtype pointers[(index, subindex)] = name diff -r d5df428640ff -r ccf59c1f0b45 connectors/WAMP/__init__.py --- a/connectors/WAMP/__init__.py Thu Aug 17 15:43:25 2017 +0300 +++ b/connectors/WAMP/__init__.py Thu Aug 17 16:26:32 2017 +0300 @@ -137,7 +137,7 @@ reactor, RegisterWampClient) if not _WampSessionEvent.wait(5): _WampConnection = stopConnecting() - raise Exception, _("WAMP connection timeout") + raise Exception(_("WAMP connection timeout")) def __del__(self): global _WampConnection diff -r d5df428640ff -r ccf59c1f0b45 editors/LDViewer.py --- a/editors/LDViewer.py Thu Aug 17 15:43:25 2017 +0300 +++ b/editors/LDViewer.py Thu Aug 17 16:26:32 2017 +0300 @@ -215,7 +215,10 @@ if rung not in rungs: rungs.append(rung) if len(rungs) > 1: - raise ValueError, _("Ladder element with id %d is on more than one rung.") % instance["id"] + raise ValueError( + _("Ladder element with id %d is on more than one rung.") + % instance["id"]) + element = self.FindElementById(instance["id"]) element_connectors = element.GetConnectors() self.Rungs[rungs[0]].SelectElement(element) @@ -231,7 +234,10 @@ if rung not in rungs: rungs.append(rung) if len(rungs) > 1: - raise ValueError, _("Ladder element with id %d is on more than one rung.") % instance["id"] + raise ValueError( + _("Ladder element with id %d is on more than one rung.") + % instance["id"]) + element = self.FindElementById(instance["id"]) element_connectors = element.GetConnectors() self.Rungs[rungs[0]].SelectElement(element) diff -r d5df428640ff -r ccf59c1f0b45 plcopen/plcopen.py --- a/plcopen/plcopen.py Thu Aug 17 15:43:25 2017 +0300 +++ b/plcopen/plcopen.py Thu Aug 17 16:26:32 2017 +0300 @@ -450,7 +450,7 @@ def appenddataType(self, name): if self.getdataType(name) is not None: - raise ValueError, "\"%s\" Data Type already exists !!!" % name + raise ValueError("\"%s\" Data Type already exists !!!" % name) self.types.appenddataTypeElement(name) setattr(cls, "appenddataType", appenddataType) @@ -505,7 +505,7 @@ def addconfiguration(self, name): if self.getconfiguration(name) is not None: - raise ValueError, _("\"%s\" configuration already exists !!!") % name + raise ValueError(_("\"%s\" configuration already exists !!!") % name) new_configuration = PLCOpenParser.CreateElement("configuration", "configurations") new_configuration.setname(name) self.instances.configurations.appendconfiguration(new_configuration) @@ -514,7 +514,7 @@ def removeconfiguration(self, name): configuration = self.getconfiguration(name) if configuration is None: - raise ValueError, ("\"%s\" configuration doesn't exist !!!") % name + raise ValueError(_("\"%s\" configuration doesn't exist !!!") % name) self.instances.configurations.remove(configuration) setattr(cls, "removeconfiguration", removeconfiguration) @@ -530,8 +530,10 @@ def addconfigurationResource(self, config_name, name): if self.getconfigurationResource(config_name, name) is not None: - msg = _("\"{a1}\" resource already exists in \"{a2}\" configuration !!!").format(a1=name, a2=config_name) - raise ValueError, msg + raise ValueError( + _("\"{a1}\" resource already exists in \"{a2}\" configuration !!!"). + format(a1=name, a2=config_name)) + configuration = self.getconfiguration(config_name) if configuration is not None: new_resource = PLCOpenParser.CreateElement("resource", "configuration") @@ -548,8 +550,10 @@ configuration.remove(resource) found = True if not found: - msg = _("\"{a1}\" resource doesn't exist in \"{a2}\" configuration !!!").format(a1=name, a2=config_name) - raise ValueError, msg + raise ValueError( + _("\"{a1}\" resource doesn't exist in \"{a2}\" configuration !!!"). + format(a1=name, a2=config_name)) + setattr(cls, "removeconfigurationResource", removeconfigurationResource) def updateElementName(self, old_name, new_name): @@ -928,7 +932,7 @@ found = True break if not found: - raise ValueError, _("\"%s\" Data Type doesn't exist !!!") % name + raise ValueError(_("\"%s\" Data Type doesn't exist !!!") % name) setattr(cls, "removedataTypeElement", removedataTypeElement) def getpouElements(self): @@ -946,7 +950,7 @@ def appendpouElement(self, name, pou_type, body_type): for element in self.pous.getpou(): if TextMatched(element.getname(), name): - raise ValueError, _("\"%s\" POU already exists !!!") % name + raise ValueError(_("\"%s\" POU already exists !!!") % name) new_pou = PLCOpenParser.CreateElement("pou", "pous") self.pous.appendpou(new_pou) new_pou.setname(name) @@ -967,7 +971,7 @@ found = True break if not found: - raise ValueError, _("\"%s\" POU doesn't exist !!!") % name + raise ValueError(_("\"%s\" POU doesn't exist !!!") % name) setattr(cls, "removepouElement", removepouElement) def Search(self, criteria, parent_infos=[]): @@ -1153,7 +1157,7 @@ if body_type in ["IL", "ST", "LD", "FBD", "SFC"]: self.body[0].setcontent(PLCOpenParser.CreateElement(body_type, "body")) else: - raise ValueError, "%s isn't a valid body type!" % type + raise ValueError("%s isn't a valid body type!" % type) setattr(cls, "setbodyType", setbodyType) def getbodyType(self): @@ -1373,7 +1377,7 @@ removed = True break if not removed: - raise ValueError, _("Transition with name %s doesn't exist!") % name + raise ValueError(_("Transition with name %s doesn't exist!") % name) setattr(cls, "removetransition", removetransition) def addaction(self, name, body_type): @@ -1414,7 +1418,7 @@ removed = True break if not removed: - raise ValueError, _("Action with name %s doesn't exist!") % name + raise ValueError(_("Action with name %s doesn't exist!") % name) setattr(cls, "removeaction", removeaction) def updateElementName(self, old_name, new_name): @@ -1507,7 +1511,7 @@ if body_type in ["IL", "ST", "LD", "FBD", "SFC"]: self.body.setcontent(PLCOpenParser.CreateElement(body_type, "body")) else: - raise ValueError, "%s isn't a valid body type!" % type + raise ValueError("%s isn't a valid body type!" % type) def getbodyType(self): @@ -1656,7 +1660,7 @@ element.setexecutionOrderId(0) self.checkedBlocksDict.clear() else: - raise TypeError, _("Can only generate execution order on FBD networks!") + raise TypeError(_("Can only generate execution order on FBD networks!")) setattr(cls, "resetexecutionOrder", resetexecutionOrder) def compileexecutionOrder(self): @@ -1670,7 +1674,7 @@ self.compileelementExecutionOrder(connections[0]) element.setexecutionOrderId(self.getnewExecutionOrderId()) else: - raise TypeError, _("Can only generate execution order on FBD networks!") + raise TypeError(_("Can only generate execution order on FBD networks!")) setattr(cls, "compileexecutionOrder", compileexecutionOrder) def compileelementExecutionOrder(self, link): @@ -1694,7 +1698,7 @@ if connections and len(connections) == 1: self.compileelementExecutionOrder(connections[0]) else: - raise TypeError, _("Can only generate execution order on FBD networks!") + raise TypeError(_("Can only generate execution order on FBD networks!")) setattr(cls, "compileelementExecutionOrder", compileelementExecutionOrder) def setelementExecutionOrder(self, instance, new_executionOrder): @@ -1710,21 +1714,21 @@ element.setexecutionOrderId(element_executionOrder + 1) instance.setexecutionOrderId(new_executionOrder) else: - raise TypeError, _("Can only generate execution order on FBD networks!") + raise TypeError(_("Can only generate execution order on FBD networks!")) setattr(cls, "setelementExecutionOrder", setelementExecutionOrder) def appendcontentInstance(self, instance): if self.content.getLocalTag() in ["LD", "FBD", "SFC"]: self.content.appendcontent(instance) else: - raise TypeError, _("%s body don't have instances!") % self.content.getLocalTag() + raise TypeError(_("%s body don't have instances!") % self.content.getLocalTag()) setattr(cls, "appendcontentInstance", appendcontentInstance) def getcontentInstances(self): if self.content.getLocalTag() in ["LD", "FBD", "SFC"]: return self.content.getcontent() else: - raise TypeError, _("%s body don't have instances!") % self.content.getLocalTag() + raise TypeError(_("%s body don't have instances!") % self.content.getLocalTag()) setattr(cls, "getcontentInstances", getcontentInstances) instance_by_id_xpath = PLCOpen_XPath("*[@localId=$localId]") @@ -1737,7 +1741,7 @@ return instance[0] return None else: - raise TypeError, _("%s body don't have instances!") % self.content.getLocalTag() + raise TypeError(_("%s body don't have instances!") % self.content.getLocalTag()) setattr(cls, "getcontentInstance", getcontentInstance) def getcontentInstancesIds(self): @@ -1745,7 +1749,7 @@ return OrderedDict([(instance.getlocalId(), True) for instance in self.content]) else: - raise TypeError, _("%s body don't have instances!") % self.content.getLocalTag() + raise TypeError(_("%s body don't have instances!") % self.content.getLocalTag()) setattr(cls, "getcontentInstancesIds", getcontentInstancesIds) def getcontentInstanceByName(self, name): @@ -1755,7 +1759,7 @@ return instance[0] return None else: - raise TypeError, _("%s body don't have instances!") % self.content.getLocalTag() + raise TypeError(_("%s body don't have instances!") % self.content.getLocalTag()) setattr(cls, "getcontentInstanceByName", getcontentInstanceByName) def removecontentInstance(self, local_id): @@ -1764,30 +1768,30 @@ if len(instance) > 0: self.content.remove(instance[0]) else: - raise ValueError, _("Instance with id %d doesn't exist!") % id + raise ValueError(_("Instance with id %d doesn't exist!") % id) else: - raise TypeError, "%s body don't have instances!" % self.content.getLocalTag() + raise TypeError(_("%s body don't have instances!") % self.content.getLocalTag()) setattr(cls, "removecontentInstance", removecontentInstance) def settext(self, text): if self.content.getLocalTag() in ["IL", "ST"]: self.content.setanyText(text) else: - raise TypeError, _("%s body don't have text!") % self.content.getLocalTag() + raise TypeError(_("%s body don't have text!") % self.content.getLocalTag()) setattr(cls, "settext", settext) def gettext(self): if self.content.getLocalTag() in ["IL", "ST"]: return self.content.getanyText() else: - raise TypeError, _("%s body don't have text!") % self.content.getLocalTag() + raise TypeError(_("%s body don't have text!") % self.content.getLocalTag()) setattr(cls, "gettext", gettext) def hasblock(self, block_type): if self.content.getLocalTag() in ["IL", "ST"]: return self.content.hasblock(block_type) else: - raise TypeError, _("%s body don't have text!") % self.content.getLocalTag() + raise TypeError(_("%s body don't have text!") % self.content.getLocalTag()) setattr(cls, "hasblock", hasblock) def updateElementName(self, old_name, new_name): @@ -2521,7 +2525,7 @@ elif opened == closed: i += 1 else: - raise ValueError, _("\"%s\" is an invalid value!") % value + raise ValueError(_("\"%s\" is an invalid value!") % value) return items diff -r d5df428640ff -r ccf59c1f0b45 svgui/pyjs/jsonrpc/django/jsonrpc.py --- a/svgui/pyjs/jsonrpc/django/jsonrpc.py Thu Aug 17 15:43:25 2017 +0300 +++ b/svgui/pyjs/jsonrpc/django/jsonrpc.py Thu Aug 17 16:26:32 2017 +0300 @@ -40,7 +40,7 @@ service.add_method(func.__name__, func) else: emsg = 'Service "%s" not found' % str(service.__name__) - raise NotImplementedError, emsg + raise NotImplementedError(emsg) return func return remotify diff -r d5df428640ff -r ccf59c1f0b45 xmlclass/xmlclass.py --- a/xmlclass/xmlclass.py Thu Aug 17 15:43:25 2017 +0300 +++ b/xmlclass/xmlclass.py Thu Aug 17 16:26:32 2017 +0300 @@ -1826,7 +1826,7 @@ if class_idx is not None and class_idx < len(element_class): new_element = element_class[class_idx]() else: - raise ValueError, "No corresponding class found!" + raise ValueError("No corresponding class found!") else: new_element = element_class() DefaultElementClass.__setattr__(new_element, "tag", self.DefaultNamespaceFormat % element_tag) diff -r d5df428640ff -r ccf59c1f0b45 xmlclass/xsdschema.py --- a/xmlclass/xsdschema.py Thu Aug 17 15:43:25 2017 +0300 +++ b/xmlclass/xsdschema.py Thu Aug 17 16:26:32 2017 +0300 @@ -396,7 +396,7 @@ # Check that item type is a simple type if itemtypeinfos["type"] != SIMPLETYPE: - raise ValueError, "Item type given isn't a simpleType!" + raise ValueError("Item type given isn't a simpleType!") simpleType["basename"] = "list"