mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-20 08:37:42 +02:00
22 lines
592 B
Python
22 lines
592 B
Python
"""Pure helpers for the app builder."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
|
|
def walk_directory(folder: str) -> dict[str, str]:
|
|
files: dict[str, str] = {}
|
|
if not os.path.isdir(folder):
|
|
return files
|
|
for root, _dirs, filenames in os.walk(folder):
|
|
for fname in filenames:
|
|
full_path = os.path.join(root, fname)
|
|
rel_path = os.path.relpath(full_path, folder)
|
|
try:
|
|
with open(full_path) as f:
|
|
files[rel_path] = f.read()
|
|
except Exception:
|
|
pass
|
|
return files
|