Skip to main content
Glama
build_context.py1.56 kB
#!/usr/bin/env python3 """ Builds an isolated tree containing all sources. """ import argparse import os import shutil import sys def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument( "--src", action="append", help="Add a source into the source tree", ) parser.add_argument("--editorconfig", help="Path for an .editorconfig file") parser.add_argument( "out_path", help="Path to output directory", ) return parser.parse_args() def main() -> int: args = parse_args() if args.editorconfig: os.makedirs(args.out_path, exist_ok=True) shutil.copy( os.path.abspath(args.editorconfig), os.path.join(args.out_path, ".editorconfig"), ) for src in args.src or []: parent_dir = os.path.dirname(src) if parent_dir: dst_dir = os.path.join(args.out_path, parent_dir) if not os.path.isdir(dst_dir): os.makedirs(dst_dir, exist_ok=True) abspath_src = os.path.abspath(src) if os.path.isdir(abspath_src): shutil.copytree( abspath_src, os.path.join(args.out_path, src), symlinks=True, dirs_exist_ok=True, ) else: shutil.copy( abspath_src, os.path.join(args.out_path, src), ) return 0 if __name__ == "__main__": sys.exit(main())

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server