From 39d1691c143f4bc16c6f1f392da641b3042a532b Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 22 May 2026 21:04:34 -0400 Subject: [PATCH] =?UTF-8?q?fc5:=20export=20script=20=E2=80=94=20add=20--ou?= =?UTF-8?q?tput=20FILE=20flag=20for=20Swarm=20one-shot=20service=20use?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/export_for_fabledcurator.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/export_for_fabledcurator.py b/scripts/export_for_fabledcurator.py index 0043aa0..a59ea96 100644 --- a/scripts/export_for_fabledcurator.py +++ b/scripts/export_for_fabledcurator.py @@ -114,6 +114,16 @@ def _export_series_pages(): def main() -> None: + import argparse + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--output", + default=None, + help="Write JSON to this path instead of stdout (use this when " + "running inside a Swarm service that writes to a bind-mount).", + ) + args = parser.parse_args() + app = create_app() with app.app_context(): export = { @@ -125,8 +135,18 @@ def main() -> None: "image_tag_associations": _export_image_tag_associations(), "series_pages": _export_series_pages(), } - json.dump(export, sys.stdout, indent=2) - sys.stdout.write("\n") + + if args.output: + from pathlib import Path + out_path = Path(args.output) + out_path.parent.mkdir(parents=True, exist_ok=True) + out_path.write_text(json.dumps(export, indent=2) + "\n") + print(f"wrote {out_path} ({len(export['tags'])} tags, " + f"{len(export['image_tag_associations'])} associations)", + file=sys.stderr) + else: + json.dump(export, sys.stdout, indent=2) + sys.stdout.write("\n") if __name__ == "__main__":