|
PCART
v1.4
Automated Repair of Python API Parameter Compatibility Issues
|
Provide utility functions for processing API calls and source files. More...
Classes | |
| class | ConditionalReturnTransformer |
| Convert conditional return statement to multi-line if-else structure 展开单行条件返回语句为多行if-else结构 More... | |
| class | UnsupportedRunCommand |
| Unsupported run command exception 不支持的运行命令异常 More... | |
Functions | |
| def | buildRunCommand (runCommand, envPath) |
| Build subprocess argv for project run command 为被测项目运行命令构造subprocess argv. More... | |
| def | cmp (version) |
| Normalize and compare version strings 归一化并比较版本号字符串 More... | |
| def | findPythonDir (basePath) |
| Get Python interpreter path 获取Python解释器路径 More... | |
| def | getAst (filePath, strFlag=0) |
| Get AST for code 将代码转化为Ast树 More... | |
| def | getImportLst (filePath) |
| Extract import statements from a source file (currently torch-specific) 从源码文件中提取import语句(目前仅筛选torch相关) More... | |
| def | getRunFile (runCommand) |
| Extract the .py script filename from a run command 从运行命令中提取.py脚本文件名 More... | |
| def | getSourceCodePath (configPath, repoRoot=None) |
| Get source code path of the lib 获取库源码路径 More... | |
| def | getVersionLst (libPath) |
| Get all version numbers from a library package directory 给定库的路径,获得该库的所有版本号 More... | |
| def | isDynamic (dic) |
| Check if a match dictionary contains dynamic (string) match results 检查匹配字典是否包含动态(字符串)匹配结果 More... | |
| def | isPyLauncher (command) |
| Check whether command is Windows py launcher 判断命令是否为Windows py启动器 More... | |
| def | isPythonExecutable (command) |
| Check whether command is a Python executable name/path 判断命令是否为Python解释器名称或路径 More... | |
| def | loadConfig (configPath) |
| Load PCART's configuration file 加载PCART配置文件 More... | |
| def | normalizeRunCommand (runCommand) |
| Normalize project run command 归一化被测项目运行命令 More... | |
| def | resolveConfigFilePath (config, repoRoot) |
| Resolve PCART config file path 解析PCART配置文件路径 More... | |
| def | resolveConfigValuePath (repoRoot, path) |
| Resolve path value loaded from PCART config 解析PCART配置字段中的路径值 More... | |
| def | resolveConsoleExecutable (envPath, commandName) |
| Resolve console script executable from a virtual environment 从虚拟环境中解析console script可执行文件 More... | |
| def | resolveLibSourceCodePath (envPath, libName) |
| Resolve the source package directory for a library in a virtual environment 从虚拟环境中解析库源码目录 More... | |
| def | resolvePythonExecutable (envPath) |
| Resolve Python executable from a virtual environment root 从虚拟环境根目录解析 Python 解释器路径 More... | |
| def | save2txt (lst, libName, runCommand, savePath) |
| Save PCART report 保存PCART报告 More... | |
| def | stripPyLauncherOption (tokens) |
| Remove version option after py launcher 去除py启动器后的版本选项 More... | |
| def | writeLine (width, s, fw) |
| Format output 格式化输出 More... | |
Provide utility functions for processing API calls and source files.
Collection of shared utility functions: AST parsing, parameter string splitting/parsing (getParameter, departAPI, departAPI2), configuration loading, run command normalization and executable resolution, report formatting (save2txt), and AST transformation (ConditionalReturnTransformer). 共享工具函数集合:AST解析、参数字符串拆分/解析(getParameter、departAPI、 departAPI2)、配置加载、运行命令归一化和可执行文件解析、报告格式化 (save2txt)、AST转换(ConditionalReturnTransformer)。
| def tool.buildRunCommand | ( | runCommand, | |
| envPath | |||
| ) |
Build subprocess argv for project run command 为被测项目运行命令构造subprocess argv.
| runCommand | The project run command |
| envPath | The virtual environment root path |
Definition at line 418 of file tool.py.
| def tool.cmp | ( | version | ) |
Normalize and compare version strings 归一化并比较版本号字符串
Converts version strings like "3.10.12", "4.5.0rc1" into a single float for comparison. Alpha/beta/rc suffixes are mapped to fractional parts (a < b < rc). 将版本号"3.10.12"、"4.5.0rc1"等转化为浮点数进行比较, alpha/beta/rc后缀映射为小数部分(a < b < rc)。
| version | The version string to normalize |
Definition at line 108 of file tool.py.
| def tool.findPythonDir | ( | basePath | ) |
| def tool.getAst | ( | filePath, | |
strFlag = 0 |
|||
| ) |
| def tool.getImportLst | ( | filePath | ) |
| def tool.getRunFile | ( | runCommand | ) |
| def tool.getSourceCodePath | ( | configPath, | |
repoRoot = None |
|||
| ) |
Get source code path of the lib 获取库源码路径
f"/dataset/zhang/anaconda3/envs/3d/lib/{pythonxx.xx}/" + f"site-packages/{torch}"
| configPath | PCART configuration path or file name under Configure |
| repoRoot | Optional PCART repository root used to resolve relative paths |
Definition at line 519 of file tool.py.
| def tool.getVersionLst | ( | libPath | ) |
| def tool.isDynamic | ( | dic | ) |
| def tool.isPyLauncher | ( | command | ) |
| def tool.isPythonExecutable | ( | command | ) |
| def tool.loadConfig | ( | configPath | ) |
Load PCART's configuration file 加载PCART配置文件
| configPath | The path of configuration file |
Definition at line 269 of file tool.py.
| def tool.normalizeRunCommand | ( | runCommand | ) |
| def tool.resolveConfigFilePath | ( | config, | |
| repoRoot | |||
| ) |
| def tool.resolveConfigValuePath | ( | repoRoot, | |
| path | |||
| ) |
Resolve path value loaded from PCART config 解析PCART配置字段中的路径值
| repoRoot | The PCART repository root path |
| path | The path value read from config |
Definition at line 299 of file tool.py.
| def tool.resolveConsoleExecutable | ( | envPath, | |
| commandName | |||
| ) |
Resolve console script executable from a virtual environment 从虚拟环境中解析console script可执行文件
| envPath | The virtual environment root path |
| commandName | Console command name |
Definition at line 390 of file tool.py.
| def tool.resolveLibSourceCodePath | ( | envPath, | |
| libName | |||
| ) |
Resolve the source package directory for a library in a virtual environment 从虚拟环境中解析库源码目录
| envPath | The virtual environment root path |
| libName | The configured public library name |
Definition at line 472 of file tool.py.
| def tool.resolvePythonExecutable | ( | envPath | ) |
| def tool.save2txt | ( | lst, | |
| libName, | |||
| runCommand, | |||
| savePath | |||
| ) |
| def tool.stripPyLauncherOption | ( | tokens | ) |
| def tool.writeLine | ( | width, | |
| s, | |||
| fw | |||
| ) |
Format output 格式化输出
Specifies the maximum width for each line of string in the file. If a line exceeds this width, it is wrapped. If the wrapped line still exceeds the maximum width, the wrapping process continues. 规定文件中每行的字符串的宽度,如果超出宽度就换行写,如果换行之后还超过了最大宽度,则继续向下换行
| width | The width of each line of string |
| s | The output string |
| fw | File writer |
Definition at line 159 of file tool.py.