将 .py 和 .pyi 后缀名改为了 .vp 和 .vpi 后缀名
This commit is contained in:
1 parent
f79c8ca643
commit
cfc30d735c
322 files changed
+246
-31772
No files matched your search
@@ -127,19 +127,19 @@ def clear_file_deps_cache() -> None:
|
||||
|
||||
|
||||
def find_reachable_files_from_entries(src_root: str, entry_files: list[str]) -> set[str]:
|
||||
"""从入口文件出发,找出所有可达的 .py 文件(通过导入关系)"""
|
||||
"""从入口文件出发,找出所有可达的 .vp/.py 文件(通过导入关系)"""
|
||||
all_files: dict[str, str] = {} # module_name -> filepath
|
||||
for root, dirs, files in os.walk(src_root):
|
||||
dirs[:] = [d for d in dirs if d not in ('__pycache__',)]
|
||||
for file in files:
|
||||
if file.endswith('.py'):
|
||||
if file.endswith('.vp') or file.endswith('.py'):
|
||||
filepath: str = os.path.join(root, file)
|
||||
rel: str = os.path.relpath(filepath, src_root)
|
||||
module: str = os.path.splitext(rel)[0].replace(os.sep, '.').replace('/', '.')
|
||||
if filepath.endswith('__init__.py'):
|
||||
if filepath.endswith('__init__.vp') or filepath.endswith('__init__.py'):
|
||||
all_files[module] = filepath
|
||||
parent_module: str = module.rsplit('.', 1)[0] if '.' in module else module
|
||||
if parent_module not in all_files or not all_files[parent_module].endswith('__init__.py'):
|
||||
if parent_module not in all_files or not (all_files[parent_module].endswith('__init__.vp') or all_files[parent_module].endswith('__init__.py')):
|
||||
all_files[parent_module] = filepath
|
||||
elif module not in all_files:
|
||||
all_files[module] = filepath
|
||||
|
||||
Reference in new issue
Block a user