def checkTree(self, T, trace=False, stop=False): self._stop = stop self._trace = trace status1 = CGM.CHECK_GOOD if (self._trace): print('### Parsing node paths...') status1 = self.checkTreeStructure(T) if (status1 != CGM.CHECK_GOOD): return status1 paths = CGU.getPathFullTree(T, width=True) sz = len(paths) + 1 ct = 1 if (not hasattr(self, 'methods')): self.methods = [] for m in inspect.getmembers(self): if ((m[0][-2:] == '_t') or (m[0][-2:] == '_n') or (m[0][-3:] == '_ts')): self.methods += [m[0]] for path in ['/'] + paths: if (self._trace): print('### Check node [%.6d/%.6d]\r' % (ct, sz), ) node = CGU.getNodeByPath(T, path) status2 = CGM.CHECK_GOOD if (node is None): status2 = self.log.push(path, 'G0005', path) if (self._stop): raise CGE.cgnsException(-1) if (status2 == CGM.CHECK_GOOD): status2 = self.checkLeaf(T, path, node) status1 = status2 ct += 1 if self._trace: print("") return status1
def checkLeaf(self, T, path, node): parent = CGU.getParentFromNode(T, node) status1 = self.checkSingleNode(T, path, node, parent) status2 = status1 ntype = CGU.getTypeAsGrammarToken(node[3]) if (len(node) == 4) and (ntype in self.methods): status2 = getattr(self, ntype)(*[path, node, parent, T, self.log]) else: # if (ntype in CGK.cgnstypes): print '\nSKIP ',ntype pass status1 = CGM.getWorst(status1, status2) if self._stop and status1 == CGM.CHECK_FAIL: raise CGE.cgnsException(-1) return status1
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