语法扩展
预计阅读时间: 小于 1 分钟```python exec="1" session="filetree" from fnmatch import fnmatch from pathlib import Path
exclude = {"dist", "site", "dest", "node_modules", ".cache", "cache", ".agent", ".git"} no_recurse = {".venv*", ".github"}
def exptree(path: str, session: str) -> None: # List files and directories separately. files = [] dirs = [] for node in Path(path).iterdir(): if any(fnmatch(node.name, pattern) for pattern in exclude): continue if node.is_dir(): dirs.append(node) else: files.append(node)