PCART  v1.4
Automated Repair of Python API Parameter Compatibility Issues
Functions
map Namespace Reference

Dynamic mapping and static mapping of API parameter definitions
More...

Functions

def dynamicMatch (callAPI, runCommand, runPath, projName, copyFile, version, virtualEnv, lock, errLst, curr=1, *callKey, runtimePaths)
 Dynamic mapping of API signatures API签名动态匹配 More...
 
def fuzzymatch (formatAPI, libName, version, builtinFlag)
 Static mapping of API signatures API签名静态匹配 More...
 
def hasSaveFailedManifest (pklKey, *runtimePaths)
 Check whether a callsite candidate manifest records pkl save failure 检查调用点候选清单是否记录了pkl保存失败 More...
 
def isAlias (callApi, assignDict)
 Check whether the last name in an API call is an alias 判断一个callAPI最后一个名字是否为库中的别名 More...
 
def mapAPI (callAPI, runCommand, runPath, formatAPI, projName, libName, copyFile, version, virtualEnv, lock, errLst, curr=1, *callKey, runtimePaths)
 Construct the mapping between the invoked API and the lib API to obtain its signature 建立invoked API与 lib API之间的映射关系,从而获取其参数定义 More...
 
def saveDynamicMatchSnapshot (pklKey, version, curr, dynamicMatchDict, pklFile=None, *runtimePaths)
 Save dynamic match result snapshot 保存动态匹配结果快照 More...
 

Detailed Description

Dynamic mapping and static mapping of API parameter definitions

Core mapping module: dynamicMatch() reconstructs API callables from runtime pkl data and uses inspect.signature() to extract signatures; fuzzymatch() provides static fallback via fuzzy name matching. mapAPI() orchestrates the two-tier strategy and manages pkl regeneration, manifest tracking, and result snapshots. 核心映射模块:dynamicMatch()从运行时pkl数据重建API可调用对象并使用 inspect.signature()提取签名;fuzzymatch()通过模糊名称匹配提供静态回退。 mapAPI()编排两级策略,管理pkl重新生成、manifest跟踪和结果快照。

Function Documentation

◆ dynamicMatch()

def map.dynamicMatch (   callAPI,
  runCommand,
  runPath,
  projName,
  copyFile,
  version,
  virtualEnv,
  lock,
  errLst,
  curr = 1,
callKey,
  runtimePaths 
)

Dynamic mapping of API signatures API签名动态匹配

Parameters
callAPIThe called API
runCommandThe run command of the project
runPathThe relative path of the run file
projNameProject name
copyFileproject's copied file
versionThe lib's version
virtualEnvThe lib's virtual environment
lockThe lock flag
errLstError list
currCurrent version flag, default is 1
callKeyUnique callsite artifact id
runtimePathsRuntime artifact paths for the current PCART workspace
Returns
dynamicMatchDict Mapped API signatures

Definition at line 164 of file map.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fuzzymatch()

def map.fuzzymatch (   formatAPI,
  libName,
  version,
  builtinFlag 
)

Static mapping of API signatures API签名静态匹配

Parameters
formatAPIThe called API
libNameThe upgraded lib
versionThe upgraded lib's version
builtinFlagBuilt-in API flag
Returns
ansDict Mapped API signatures

Definition at line 57 of file map.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasSaveFailedManifest()

def map.hasSaveFailedManifest (   pklKey,
runtimePaths 
)

Check whether a callsite candidate manifest records pkl save failure 检查调用点候选清单是否记录了pkl保存失败

Parameters
pklKeyThe callsite key used to locate the manifest
runtimePathsRuntime artifact paths for the current PCART workspace
Returns
result Whether any candidate was covered but failed to save

Definition at line 129 of file map.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAlias()

def map.isAlias (   callApi,
  assignDict 
)

Check whether the last name in an API call is an alias 判断一个callAPI最后一个名字是否为库中的别名

Parameters
callApiThe called API to be checked
assignDictThe assign dict stores the alias of APIs
Returns
realName The real name of the called API or None

Definition at line 34 of file map.py.

Here is the caller graph for this function:

◆ mapAPI()

def map.mapAPI (   callAPI,
  runCommand,
  runPath,
  formatAPI,
  projName,
  libName,
  copyFile,
  version,
  virtualEnv,
  lock,
  errLst,
  curr = 1,
callKey,
  runtimePaths 
)

Construct the mapping between the invoked API and the lib API to obtain its signature 建立invoked API与 lib API之间的映射关系,从而获取其参数定义

先进行动态匹配,动态匹配的结果是保存在api_dynamic.json文件中的 动态匹配的成功包括3步:1.加载PKL; 2.动态脚本执行成功,3.动态获取参数成功(部分内置api无法获取参数)

Parameters
callAPIThe called API
runCommandThe run command of the project
runPathThe relative path of the run file
formatAPIThe restored API string used for static matching
projNameProject name
libNameThe lib's name
copyFileproject's copied file
versionThe lib's version
virtualEnvThe lib's virtual environment
lockThe lock flag
errLstError list
currCurrent version flag, default is 1
callKeyUnique callsite artifact id
runtimePathsRuntime artifact paths for the current PCART workspace
Returns
ans Mapped API signatures

Definition at line 328 of file map.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveDynamicMatchSnapshot()

def map.saveDynamicMatchSnapshot (   pklKey,
  version,
  curr,
  dynamicMatchDict,
  pklFile = None,
runtimePaths 
)

Save dynamic match result snapshot 保存动态匹配结果快照

Parameters
pklKeyThe callsite key used to locate the pkl/json data
versionThe lib version used in this dynamic match
currCurrent version flag, 1 for current and 0 for target
dynamicMatchDictDynamic match result loaded from dynamicMatch.py
pklFileThe pkl candidate file used by this dynamic match
runtimePathsRuntime artifact paths for the current PCART workspace
Returns
None

Definition at line 97 of file map.py.

Here is the call graph for this function:
Here is the caller graph for this function: