18 from Tool.tool
import cmp
32 repoRoot=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
33 libPath=os.path.join(repoRoot,
'LibAPIExtraction',libName,f
'{libName}{version}')
34 f = open(libPath,
'r', encoding=
'utf-8')
42 if item[0]!=
'\n' and item[0]!=
'-':
43 item=item.replace(
' ',
'').replace(
'\n',
'')
45 item=item.replace(
'\n',
'')
49 assignDict[temp[0]]=temp[1]
58 if item[0]!=
'\n' and item[0]!=
'A':
59 item=item.replace(
'\n',
'')
60 libAPIIns.append(item)
66 for k,v
in assignDict.items():
69 assignDict[k]=assignDict[v]
71 tempLst=list(set(libAPIs))
72 tempLst.sort(key=libAPIs.index)
73 return tempLst,assignDict,libAPIIns
83 def func(libApiObjLst,libApiName):
85 for it
in libApiObjLst:
86 if it.name==libApiName:
87 lst.append(it.full_item)
101 pattern_v=
r'\d+\.(?:\d+\.)*\d+'
102 obj_v=re.compile(pattern_v)
103 version=obj_v.findall(filePath)[0]
105 f = open(filePath,
'r', encoding=
'utf-8')
109 if it[0]!=
'A' and it[0]!=
'-' and it[0]!=
'\n':
110 it=it.replace(
' ',
'').replace(
'\n',
'')
115 tempLst=list(set(ans))
116 tempLst.sort(key=ans.index)
117 return version,tempLst
131 pathObj.getPath(sourceFilePath)
139 apiObj.toAPIObj(version,apiLst)
140 for it
in apiObj.objLst:
141 if it.name
not in dic:
145 lst=
func(apiObj.objLst,it.name)
148 if subDic
not in dic[it.name]:
149 dic[it.name].append(subDic)
152 for value
in dic.values():
153 value.sort(key=
lambda it:
cmp([v
for v
in it.keys()][0]))
157 fw = open(saveFilePath,
'w', encoding=
'utf-8')
158 json.dump(dic,fw,indent=4,ensure_ascii=
False)
160 print(f
"API total number={len(dic)}")
162 for api,subLst
in dic.items():
163 for subDict
in subLst:
165 for version,ssubLst
in subDict.items():
167 print(f
"Multiple over loads:{api} at {version}")
def loadLib(libName, version)
Load the extracted definitions of lib APIs for static signature mapping 把之前抽取出来的库API加载到字典中,在项目API与库AP...
def lib2json(sourceFilePath, saveFilePath)
Traverse all library API versions and consolidate into a JSON file 遍历所有版本的库API,将其整理成一个json格式的文件
def getAPILst(filePath)
Parse API list from a library extraction file 从库API提取文件中解析API列表
def func(libApiObjLst, libApiName)
Get all overloaded API strings for a given API name 获取给定API名称的所有重载API字符串