fix: workspace_tree 叶子判定排除 __pycache__(与扫描一致)
tests/detector 仅含 __pycache__ 子目录,之前 is_leaf 判定把它算作子目录导致误标非叶子。 修正:叶子判定排除隐藏目录和 __pycache__,与下方目录扫描规则一致。
This commit is contained in:
parent
d5fc14ae1c
commit
b601dc94c3
@ -50,11 +50,14 @@ for name in entries:
|
||||
if name.startswith('.') or name == '__pycache__':
|
||||
continue
|
||||
if os.path.isdir(full):
|
||||
# 叶子判定:目录下是否还有子目录(排除隐藏目录)。无子目录 → 叶子(不可展开)
|
||||
# 叶子判定:目录下是否还有「可见」子目录(排除隐藏目录和 __pycache__,与下方扫描一致)。
|
||||
# 无可见子目录 → 叶子(不可展开)
|
||||
has_subdir = False
|
||||
try:
|
||||
for sub in os.listdir(full):
|
||||
if not sub.startswith('.') and os.path.isdir(os.path.join(full, sub)):
|
||||
if sub.startswith('.') or sub == '__pycache__':
|
||||
continue
|
||||
if os.path.isdir(os.path.join(full, sub)):
|
||||
has_subdir = True
|
||||
break
|
||||
except Exception:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user