Beispiel #1
0
 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))
Beispiel #2
0
 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
Beispiel #3
0
 def test_06NodeType(self):
     import CGNS.PAT.cgnsutils as CGU
     import CGNS.PAT.cgnserrors as CGE
     import CGNS.PAT.cgnskeywords as CGK
     A = ['A', None, [], None]
     B = ['B', None, [], None]
     C = ['C', None, [], None]
     D = ['D', None, [], None]
     A[2] += [B]
     A[2] += [C]
     C[3] = 'UnknownType_t'
     self.assertFalse(CGU.checkNodeType(C))
     self.assertFalse(CGU.checkNodeType(C, [CGK.CGNSBase_ts, CGK.Zone_ts]))
     self.assertFalse(CGU.checkNodeType(C, CGK.CGNSBase_ts))
     C[3] = CGK.CGNSBase_ts
     self.assertTrue(CGU.checkNodeType(C))
     self.assertTrue(CGU.checkNodeType(C, [CGK.CGNSBase_ts, CGK.Zone_ts]))
     self.assertTrue(
         CGU.checkNodeType(C, [CGK.Zone_ts, CGK.CGNSBase_ts, CGK.Zone_ts]))
     self.assertTrue(CGU.checkNodeType(C, CGK.CGNSBase_ts))