将 .py 和 .pyi 后缀名改为了 .vp 和 .vpi 后缀名
This commit is contained in:
@@ -89,7 +89,7 @@ class TransPyC:
|
||||
FileType: str | None = SymbolFile.FileType
|
||||
if not FileType and SymbolFile.FilePath:
|
||||
# 从文件路径推断类型
|
||||
if SymbolFile.FilePath.endswith('.py'):
|
||||
if SymbolFile.FilePath.endswith('.vp') or SymbolFile.FilePath.endswith('.py'):
|
||||
FileType = 'py'
|
||||
elif SymbolFile.FilePath.endswith('.c') or SymbolFile.FilePath.endswith('.h'):
|
||||
FileType = 'c'
|
||||
@@ -298,7 +298,7 @@ class TransPyC:
|
||||
|
||||
# 如果没有指定输出文件,使用默认名称
|
||||
if not OutputFile:
|
||||
OutputFile = InputFile.replace('.py', '.symbin').replace('.c', '.symbin')
|
||||
OutputFile = InputFile.replace('.vp', '.symbin').replace('.py', '.symbin').replace('.c', '.symbin')
|
||||
|
||||
# 执行预处理
|
||||
self.Args['PreSym'] = {
|
||||
@@ -599,7 +599,7 @@ class TransPyC:
|
||||
encoding: str = self.Args.get('Encoding', 'utf-8')
|
||||
|
||||
# 推断文件类型
|
||||
FileType: str | None = 'py' if InputFile.endswith('.py') else 'c' if InputFile.endswith('.c') else None
|
||||
FileType: str | None = 'py' if (InputFile.endswith('.vp') or InputFile.endswith('.py')) else 'c' if InputFile.endswith('.c') else None
|
||||
|
||||
# 创建 SymbolFile 对象,传入编码参数
|
||||
SymbolFile: SymbolFile = SymbolFile(file=InputFile, type=FileType, encoding=encoding)
|
||||
@@ -629,11 +629,11 @@ class TransPyC:
|
||||
# 没有命令行参数,使用默认的测试文件名称
|
||||
InputFile: str = DEFAULT_INPUT_FILE
|
||||
OutputFile: str = DEFAULT_OUTPUT_FILE
|
||||
info('使用默认测试文件: test.py -> test.c')
|
||||
info('使用默认测试文件: test.vp -> test.c')
|
||||
|
||||
FileType: str = DetectFileType(InputFile)
|
||||
|
||||
if FileType == '.py':
|
||||
if FileType in ('.vp', '.py'):
|
||||
self.PythonToC(InputFile, OutputFile)
|
||||
# 检查是否需要编译和运行
|
||||
if 'CompileCommand' in self.Args or self.Args.get('Run', False):
|
||||
|
||||
Reference in New Issue
Block a user