From 6a1d83dc6d29b041ae9f8f3c908abc7c306ee9c6 Mon Sep 17 00:00:00 2001 From: polyfloyd Date: Sun, 6 Jul 2025 16:46:21 +0200 Subject: [PATCH] Set exit status when identify matches nothing --- beangulp/__init__.py | 7 +++++++ beangulp/tests/identify.rst | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/beangulp/__init__.py b/beangulp/__init__.py index eef15a70..b073b682 100644 --- a/beangulp/__init__.py +++ b/beangulp/__init__.py @@ -254,6 +254,8 @@ def _identify(ctx: "Ingest", src: str, failfast: bool, verbose: bool): log = utils.logger(verbose) errors = exceptions.ExceptionsTrap(log) + any_importer_found = False + for filename in _walk(src, log): with errors: importer = identify.identify(ctx.importers, filename) @@ -261,6 +263,8 @@ def _identify(ctx: "Ingest", src: str, failfast: bool, verbose: bool): log("") # Newline. continue + any_importer_found = True + # Signal processing of this document. log(" ...", nl=False) @@ -277,6 +281,9 @@ def _identify(ctx: "Ingest", src: str, failfast: bool, verbose: bool): if errors: sys.exit(1) + if not any_importer_found: + sys.exit(100) + def _importer(importer): """Check that the passed instance implements the Importer interface. diff --git a/beangulp/tests/identify.rst b/beangulp/tests/identify.rst index 7b8f31b6..e649cb55 100644 --- a/beangulp/tests/identify.rst +++ b/beangulp/tests/identify.rst @@ -55,7 +55,7 @@ Test with an empty downloads directory: >>> r = run('identify', downloads) >>> r.exit_code - 0 + 100 >>> print(r.output) Add some documents: