1from collections import deque 2import TestScripts.Parser 3 4# When deprecation is forced on some nodes 5# we ensure that a parent of a valid node is also valid 6def correctDeprecation(node): 7 current = node.data["deprecated"] 8 for c in node.children: 9 if not correctDeprecation(c): 10 current = False 11 node.data["deprecated"] = current 12 return(current) 13 14def inheritDeprecation(node,deprecated): 15 current = node.data["deprecated"] or deprecated 16 node.data["deprecated"] = current 17 if node.kind != TestScripts.Parser.TreeElem.TEST: 18 for c in node.children: 19 inheritDeprecation(c,current) 20 21 22def deprecateRec(root,others,deprecated): 23 if others: 24 newOthers=others.copy() 25 newOthers.popleft() 26 if root.kind == TestScripts.Parser.TreeElem.TEST: 27 if others[0].isdigit() and int(root.id) == int(others[0]): 28 root.data["deprecated"]=False 29 for c in root.children: 30 deprecateRec(c,newOthers,False) 31 else: 32 root.data["deprecated"]=True 33 for c in root.children: 34 deprecateRec(c,others,deprecated) 35 else: 36 if root.data["class"] == others[0]: 37 root.data["deprecated"]=False 38 for c in root.children: 39 deprecateRec(c,newOthers,False) 40 else: 41 root.data["deprecated"]=deprecated 42 for c in root.children: 43 deprecateRec(c,others,deprecated) 44 45def deprecate(root,others): 46 inheritDeprecation(root,False) 47 if others: 48 deprecateRec(root,deque(others),True) 49 correctDeprecation(root)