Initial Frame Flow read-only Console adapter
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Package an independently maintained adapter without Console internals."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
from zipfile import ZIP_DEFLATED, ZipFile
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("directory", type=Path)
|
||||
parser.add_argument("output", type=Path)
|
||||
args = parser.parse_args()
|
||||
root = args.directory.resolve()
|
||||
manifest = json.loads((root / "manifest.json").read_text())
|
||||
entry = (root / manifest["entrypoint"]).resolve()
|
||||
if not entry.is_relative_to(root) or not entry.is_file():
|
||||
parser.error("invalid adapter entrypoint")
|
||||
with ZipFile(args.output, "w", ZIP_DEFLATED) as archive:
|
||||
for path in sorted(root.rglob("*")):
|
||||
if path.is_symlink():
|
||||
parser.error("symlinks are not supported")
|
||||
if (
|
||||
path.is_file()
|
||||
and path.resolve() != args.output.resolve()
|
||||
and not any(part in (".git", "__pycache__") for part in path.parts)
|
||||
and path.suffix != ".pyc"
|
||||
):
|
||||
archive.write(path, path.relative_to(root))
|
||||
print("Adapter package created:", args.output)
|
||||
Reference in New Issue
Block a user