|
PCART
v1.4
Automated Repair of Python API Parameter Compatibility Issues
|
Provide utility functions for API strings, parameters and artifact file names. More...
Functions | |
| def | departAPI (s) |
| Split API call string based on parameter passing 根据参数传递拆分API调用字符串 More... | |
| def | departAPI2 (s, separator='.') |
| Split API call string based on separator "." 根据"."拆分API调用字符串 More... | |
| def | getArtifactDisplayName (artifactId) |
| Return readable artifact display name 返回可读运行产物展示名 More... | |
| def | getArtifactHash (artifactId) |
| Return artifact hash from an artifact id 从运行产物id中提取hash. More... | |
| def | getFileName (fileName, extension) |
| Normalize and sanitize file name 规范化并清理文件名 More... | |
| def | getLastAPIParameter (apiStr) |
| Get parameter(s) of the last API from the API call string 获取最后一个API参数 More... | |
| def | getParameter (p_string, separator=',', space=1) |
| Split parameter string into list of separated parameters 将参数字符串拆分成单个的参数 More... | |
| def | removeParameter (s, flag=0) |
| Remove parameter(s) from API call string 去掉API中的参数部分 More... | |
| def | shortenArtifactFileName (fileName, extension) |
| Shorten artifact file name while preserving full hash 缩短运行产物文件名并保留完整hash. More... | |
Variables | |
| ARTIFACT_HASH_PATTERN = re.compile(r'(?:^|__)([0-9a-f]{64})$') | |
Provide utility functions for API strings, parameters and artifact file names.
Provides API string splitting, parameter extraction, artifact hash extraction and file name normalization. 提供API字符串拆分、参数提取、运行产物hash提取和文件名规范化的工具函数。
| def codeUtils.departAPI | ( | s | ) |
Split API call string based on parameter passing 根据参数传递拆分API调用字符串
For example, a.b(x).c(y).d(z) --> ['a.b(x)', 'a.b(x).c(y)', 'a.b(x).c(y).d(z)'] 比如a.b(x).c(y).d(z)拆成3个API,分别是['a.b(x)', 'a.b(x).c(y)', 'a.b(x).c(y).d(z)'] 还有特殊的调用形式a.b['x'](y)
| s | The API call string |
Definition at line 143 of file codeUtils.py.
| def codeUtils.departAPI2 | ( | s, | |
separator = '.' |
|||
| ) |
Split API call string based on separator "." 根据"."拆分API调用字符串
For example, a.b(x).c(y).d(z) --> ['a', 'b(x)', 'c(y)', 'd(z)'] 比如a.b(x).c(y).d(z)拆成4个API,分别是['a', 'b(x)', 'c(y)', 'd(z)']
| s | The API call string |
| separator | The separator symbol: . |
Definition at line 190 of file codeUtils.py.
| def codeUtils.getArtifactDisplayName | ( | artifactId | ) |
Return readable artifact display name 返回可读运行产物展示名
| artifactId | The artifact id |
Definition at line 33 of file codeUtils.py.
| def codeUtils.getArtifactHash | ( | artifactId | ) |
Return artifact hash from an artifact id 从运行产物id中提取hash.
| artifactId | The artifact id |
Definition at line 21 of file codeUtils.py.
| def codeUtils.getFileName | ( | fileName, | |
| extension | |||
| ) |
Normalize and sanitize file name 规范化并清理文件名
| fileName | Typically, the API call string or callsite artifact id is input as the file name |
| extension | The extension of the file |
Definition at line 66 of file codeUtils.py.
| def codeUtils.getLastAPIParameter | ( | apiStr | ) |
Get parameter(s) of the last API from the API call string 获取最后一个API参数
For example, a(x).b(x=c.d(1),y=b((1,2),5),w).c(1,2,3,4) --> 1,2,3,4 比如,a(x).b(x=c.d(1),y=b((1,2),5),w).c(1,2,3,4),获取c的参数1,2,3,4
| apiStr | The API call string |
Definition at line 334 of file codeUtils.py.
| def codeUtils.getParameter | ( | p_string, | |
separator = ',', |
|||
space = 1 |
|||
| ) |
Split parameter string into list of separated parameters 将参数字符串拆分成单个的参数
apiName(x,y="<bold>Hello, World!</bold>",z:int,w=(p1,p2={1,(1m,23)}),device: Union[Device, int] = None, abbreviated: bool ={'a','b'}) -> str 默认按逗号进行拆分,也可按'.'进行拆分,比如a.b.c 拆分参数的时候没有考虑到x="hello,world"带冒号的情况,会错误拆成两个
| p_string | Parameter string |
| separator | The separator, ',' is the default value |
| space | Determine whether to remove the space in the parameter string |
Definition at line 244 of file codeUtils.py.
| def codeUtils.removeParameter | ( | s, | |
flag = 0 |
|||
| ) |
Remove parameter(s) from API call string 去掉API中的参数部分
For example, a.b(x,y(2)).c(z=1).d(w=[(1,2)]) --> a.b.c.d 比如a.b(x,y(2)).c(z=1).d(w=[(1,2)])变成a.b.c.d
| s | The API call string |
| flag | Determine remove all parameters or the last parameter for the input API call: 0 for all parameters; 1 for the last parameters |
Definition at line 90 of file codeUtils.py.
| def codeUtils.shortenArtifactFileName | ( | fileName, | |
| extension | |||
| ) |
Shorten artifact file name while preserving full hash 缩短运行产物文件名并保留完整hash.
| fileName | The artifact file stem |
| extension | The extension of the file |
Definition at line 47 of file codeUtils.py.
| ARTIFACT_HASH_PATTERN = re.compile(r'(?:^|__)([0-9a-f]{64})$') |
Definition at line 13 of file codeUtils.py.