PCART  v1.4
Automated Repair of Python API Parameter Compatibility Issues
extractLibAPI.py
Go to the documentation of this file.
1 
9 
10 
11 
12 import json
13 import sys
14 from Extract.getDef import getDefFunction
15 from Tool.tool import getSourceCodePath,resolveConfigFilePath
16 from Tool.workspace import getRepoRoot
17 
18 
19 
20 
26 def getLibAPI(version, libName, sourceCodePath):
27  getDefFunction((libName, version, sourceCodePath))
28 
29 
30 
31 
33 def main():
34  if len(sys.argv) < 3:
35  print("Usage: python extractLibAPI.py -cfg config.json")
36  sys.exit(1)
37 
38  config=sys.argv[2]
39  repoRoot=getRepoRoot()
40  configPath=resolveConfigFilePath(config,repoRoot)
41 
42  #加载配置
43  with open(configPath,'r',encoding='UTF-8') as fr:
44  libName=json.load(fr)['libName']
45  currentVersion, targetVersion, currentSourceCodePath, targetSourceCodePath = getSourceCodePath(configPath,repoRoot)
46 
47  #抽取起始版本API定义
48  print(currentVersion, currentSourceCodePath)
49  getLibAPI(currentVersion, libName, currentSourceCodePath)
50 
51  #抽取目标版本API定义
52  print(targetVersion, targetSourceCodePath)
53  getLibAPI(targetVersion, libName, targetSourceCodePath)
54 
55 if __name__=='__main__':
56  main()
def main()
Main function of extracting lib API definitions 抽取库API定义主函数
def getLibAPI(version, libName, sourceCodePath)
Extract API definitions for a given library version 抽取给定库版本的API定义
def getDefFunction(args)
Extract all lib API definitions from a specified version 抽取给定版本的库API定义
Definition: getDef.py:597
Definition: main.py:1
def getSourceCodePath(configPath, repoRoot=None)
Get source code path of the lib 获取库源码路径
Definition: tool.py:866
def resolveConfigFilePath(config, repoRoot)
Resolve PCART config file path 解析PCART配置文件路径
Definition: tool.py:632
def getRepoRoot()
Get PCART repository root path 获取PCART仓库根目录路径
Definition: workspace.py:52