-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathAnalyzeLibInfo.py
More file actions
89 lines (81 loc) · 2.91 KB
/
AnalyzeLibInfo.py
File metadata and controls
89 lines (81 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python3
# AnalyzeLibInfo.py
import os
from pprint import pprint
libPaths = {}
libReport = ""
folderPath = ""
def infoFromFile(filename):
global folderPath
libInfo = []
f=open(folderPath+"/"+filename)
infoStr = f.read()
f.close()
libInfo = eval(infoStr)
return libInfo
def writeReportFile():
global libReport
fileName = "LibraryAnalysisReport.txt"
print("WRITING FILE: "+fileName)
fo=open(fileName, 'w')
fo.write(libReport)
fo.close()
def collectLibFilenamesFromFolder():
global libPaths
global folderPath
folderPath = os.getcwd()+"/testLibResults"
for filename in os.listdir(folderPath):
if filename.endswith("Lib.dog.info"):
dotPos=filename.find(".")
libKey = filename[:dotPos]
if not libKey in libPaths:
parent = ""
children = []
libPaths[libKey] = {"parent":parent, "children":children}
if filename == libKey+".Lib.dog.info":
libPaths[libKey]["parent"]=filename
else:
libPaths[libKey]["children"].append(filename)
def findInChild(className, parentID, childInfo):
#print(parentID)
for childClass in childInfo[0][1]:
childClassName = childClass['className']
if childClassName == className:
for childField in childClass['fields']:
childID = childField['fieldID']
if childID == parentID:
if childField['status'] == 'Impl':return True
else: return childField['status']
return False
def analyzeParentChild(parent, child):
global libReport
libReport = libReport + "CHILD LIB: "+ child + "\n"
parentInfo = infoFromFile(parent)
childInfo = infoFromFile(child)
for parentClass in parentInfo[0][1]:
if len(parentClass['fields'])==0: continue
className = parentClass['className']
#print(className)
for parentField in parentClass['fields']:
if 'status' in parentField:
if parentField['status'] != 'Impl':
parentID = parentField['fieldID']
found = findInChild(className, parentID, childInfo)
if found == False:
libReport = libReport + " " + parentID + " missing in child.\n"
elif found != True:
libReport = libReport + " " + parentID + " is " + found+ " in child.\n"
#print(libReport)
def getParentChild():
global libPaths
for libKey in libPaths:
if len(libPaths[libKey]) < 2: continue
parent = libPaths[libKey]["parent"]
children = libPaths[libKey]["children"]
if len(children) == 0:continue
if libKey == "List": continue
for child in children:
analyzeParentChild(parent, child)
collectLibFilenamesFromFolder()
getParentChild()
writeReportFile()