INNER CODE UNIT · Python
_public_symlinks
WenyuChiou/awesome-agentic-ai-zh · scripts/build-docs-tree.py:79
def _public_symlinks(sources: list[Path]) -> list[Path]:
"""Find symlinks without following them into an external tree."""
found: set[Path] = set()
for source in sources:
if source.is_symlink():
found.add(source)
continue
if not source.is_dir():
continue
for directory, dirnames, filenames in os.walk(source, followlinks=False):
parent = Path(directory)
for name in (*dirnames, *filenames):
candidate = parent / name
if candidate.is_symlink():
found.add(candidate)
return sorted(found)