def test_04NodeChildren(self): import CGNS.PAT.cgnsutils as CGU import CGNS.PAT.cgnslib as CGL import CGNS.PAT.cgnserrors as CGE import CGNS.PAT.cgnskeywords as CGK A = ['A', None, [], None] B = ['B', None, [], None] C = ['C', None, [], None] A[2] += [B] CGU.setAsChild(A, C) self.assertTrue(CGU.hasChildName(A, 'B')) self.assertTrue(CGU.hasChildName(A, 'C')) self.assertTrue(CGU.checkDuplicatedName(A, 'D')) self.assertFalse(CGU.checkHasChildName(A, 'D')) D = CGU.nodeCreate('D', None, [], None, parent=A) self.assertFalse(CGU.checkDuplicatedName(A, 'D')) self.assertTrue(CGU.checkHasChildName(A, 'D')) self.assertFalse(CGU.checkNodeType(C)) d = { 'None': None, 'String': 'string value', 'Integer': 10, 'Float': 1.4 } for n, v in d.items(): CGL.newDataArray(A, n, v) for name in d.keys(): self.assertTrue(CGU.hasChildName(A, name))
def linkadd(self): if (self._control.selectForLinkDst is None): return dst = self._control.selectForLinkDst str_dst = "%s:%s" % (dst[3], dst[1]) tpath = 'relative' newname = CGU.getPathLeaf(dst[1]) if (CGU.checkDuplicatedName(self.selectForLinkSrc[0].sidsNode(), newname, dienow=False)): str_cnm = "New child node name is <b>%s</b>" % newname else: count = 0 while (not CGU.checkDuplicatedName( self.selectForLinkSrc[0].sidsNode(), newname, dienow=False)): count += 1 newname = '{%s#%.3d}' % (dst[0].sidsType(), count) str_cnm = """As a child with this name already exists, the name <b>%s</b> is used (generated name)""" % \ newname str_src = "%s:%s/%s" % (self.FG.filename, self.selectForLinkSrc[1], newname) str_msg = "you want to create a link from <b>%s</b> to <b>%s</b><br>%s<br>Your current user options do force " \ "the link to use <b>%s</b> destination file path.""" % ( str_src, str_dst, str_cnm, tpath) reply = MSG.wQuestion(self, 231, 'Create link as a new node', str_msg)
def checkLeafStructure(self, T, path, node, parent): stt = CGM.CHECK_GOOD try: CGU.checkNode(node, dienow=True) CGU.checkNodeName(node, dienow=True) CGU.checkDuplicatedName(parent, node[0], dienow=True) CGU.checkNodeType(node, dienow=True) if (node[1] is not None): CGU.checkArray(node[1], dienow=True) except CGE.cgnsException as v: if (v.code == 1): stt = self.log.push(path, 'G0010') if (v.code == 2): stt = self.log.push(path, 'G0009') if (v.code == 3): stt = self.log.push(path, 'G0008') if (v.code == 4): stt = self.log.push(path, 'G0007') if (v.code == 5): stt = self.log.push(path, 'G0006') if (v.code == 22): stt = self.log.push(path, 'G0008') if (v.code == 23): stt = self.log.push(path, 'G0011') if (v.code == 24): stt = self.log.push(path, 'G0012') if (v.code == 25): stt = self.log.push(path, 'G0014') if (v.code == 29): stt = self.log.push(path, 'G0013') if (v.code == 31): stt = self.log.push(path, 'G0011') if (v.code == 32): stt = self.log.push(path, 'G0011') if (v.code == 111): stt = self.log.push(path, 'G0015') if (self._stop): raise CGE.cgnsException(-1) return stt