From bf5b534022c683304a29038f0dbb9f41b2276c04 Mon Sep 17 00:00:00 2001 From: Kai Schleicher Date: Wed, 28 Oct 2026 17:29:43 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20save=5Fscript=5Fparameters:=20sk?= =?UTF-8?q?ip=20whole=20names=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The skip list ("USERNAME", "SJLOG", "COMMAND", "RM") was matched as a substring, so e.g. a parameter "fusion_format" (contains "RM") was not saved. Match the whole name (case insensitive), as documented. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 3 +++ src/imcflibs/imagej/misc.py | 5 +++-- tests/test_misc.py | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2647f020..2cae61fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,9 @@ multiple modules. For detailed information, please refer to the * `imcflibs.imagej.misc.run_imarisconvert`: * Now allows to select an output folder. * Adds pixel calibration to the converted file. +* `imcflibs.imagej.misc.save_script_parameters` skips only parameters whose + whole name is in the skip list (`fusion_format` was skipped because it + contains `RM`). * `imcflibs.imagej.misc.subtract_images` now validates the slice count is equal for both images. * `imcflibs.imagej.misc.save_image_with_extension`: fix issue with java path diff --git a/src/imcflibs/imagej/misc.py b/src/imcflibs/imagej/misc.py index 045301db..b1771eed 100644 --- a/src/imcflibs/imagej/misc.py +++ b/src/imcflibs/imagej/misc.py @@ -843,8 +843,9 @@ def save_script_parameters( for item in script_info.inputs(): key = item.getName() - # Skip if any keys are in the skip list - if any(skip in key.upper() for skip in skip_keys): + # Skip if the key is in the skip list (whole name, not a substring: + # e.g. "FUSION_FORMAT" contains "RM") + if key.upper() in skip_keys: log.info("Skipping parameter from skip-list: %s", key) skipped += 1 continue diff --git a/tests/test_misc.py b/tests/test_misc.py index 9f137cb7..346fe55f 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -51,6 +51,24 @@ def _is_password_style(item): assert contents == "AAA: aaa\nBBB: bbb\n" +def test_save_script_parameters_skip_whole_names(tmp_path, monkeypatch, caplog): + """Only whole names are skipped, case insensitive, not substrings.""" + caplog.set_level(logging.DEBUG) + caplog.clear() + monkeypatch.setattr(imcflibs.imagej.misc, "_is_password_style", lambda item: False) + + script_module = ScriptModule( + input_names=["rm", "fusion_format", "commander"], + inputs={"rm": "roimanager", "fusion_format": "TIFF", "commander": "x"}, + ) + script_globals = {"org.scijava.script.ScriptModule": script_module} + save_script_parameters(script_globals, destination=tmp_path) + + with open(str(tmp_path) + "/script_parameters.txt", "r") as f: + contents = f.read() + assert contents == "fusion_format: TIFF\ncommander: x\n" + + def test_bytes_to_human_readable_simple(): """Ensure common sizes are formatted into human-readable strings.""" assert bytes_to_human_readable(500) == "500.0 bytes"