Files
openswarm/backend/apps/app_builder/helpers.py
T

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