def convertTaskToModel(self) -> list: """ task节点转tableview model. :return: list数组,元素为dict类型 """ # 定位tasks节点 node = xml.findFirstNode(self.xmlTree, ".//tasks") return [subNode.attrib for subNode in list(node)]
def convertFunctionToModel(self) -> list: """ function节点转tableview model. :return: list数组,元素为dict类型 """ # 定位functions节点 node = xml.findFirstNode(self.xmlTree, ".//functions") return [subNode.attrib for subNode in list(node)]
def delNodeNode(self, id: str): """ 删除节点节点. :param id: 要删除的节点id :return: """ node = xml.findFirstNode(self.xmlTree, r".//nodes") self.__delNode(node, {"rowId": id})
def delFunctionNode(self, id: str): """ 删除功能节点. :param id: 要删除的节点id :return: """ node = xml.findFirstNode(self.xmlTree, r".//functions") self.__delNode(node, {"rowId": id})
def delThreadNode(self, id: str): """ 删除线程节点. :param id: 要删除的节点id :return: """ node = xml.findFirstNode(self.xmlTree, r".//threads") self.__delNode(node, {"rowId": id})
def __addNode(self, nodeTag: str, chidNodeTag: str, attrsMap: dict = {}): """ 添加子节点. :param nodeTag: 当前节点标签 :param chidNodeTag: 子节点标签 :param attrsMap: 子节点属性 :return: """ # 查找节点 node = xml.findFirstNode(self.xmlTree, r".//%s" % nodeTag) # 新建子节点 childNode = xml.createNode(chidNodeTag, attrsMap) # 添加thread节点 xml.addChildNode(node, childNode) # 保存xml文件 self.saveXml()