emergent-security/tools/export_knowledge.py

27 lines
915 B
Python
Raw Normal View History

#!/usr/bin/env python3
"""Export a self-contained orientation bundle into a new directory (no overwrite)."""
from pathlib import Path
import argparse
import shutil
import sys
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
from emergent_security.knowledge import Knowledge, confined
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("destination", type=Path)
args = parser.parse_args()
package = Knowledge()
args.destination.mkdir(parents=True, exist_ok=False)
for name in ["release.yaml", *package.release["files"]]:
target = confined(args.destination, name)
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(confined(package.root, name), target)
print(f"Exported orientation-only package {package.catalog['version']} ({package.package_digest})")
if __name__ == "__main__":
main()