gradio_motioncanvas_mcp_server / extract_examples.py
Patrick Rathje
add example extraction
e5509f7
raw
history blame
635 Bytes
import os
import glob
from pathlib import Path
assert os.environ['MC_EXAMPLE_SCENES_DIR']
assert os.environ['MC_EXAMPLES_MD_FILE']
with open(os.environ['MC_EXAMPLES_MD_FILE'], "w") as f:
f.write(f"# Examples for Motion Canvas Scenes in TypeScript\n")
for filepath in glob.iglob(os.environ['MC_EXAMPLE_SCENES_DIR'] + '/**/*.tsx', recursive=True):
name = Path(filepath).stem
f.write(f"\n\n## {name}\n")
# read the file
with open(filepath, 'r') as scene_file:
content = scene_file.read()
f.write(f"```tsx\n")
f.write(content)
f.write(f"```\n")