From 68c7b76a1e7d211529b0305d21fa9676d09cc0c4 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Mon, 28 Jan 2019 17:18:35 +0100 Subject: [PATCH] Add workaround for Jython issue reading ImageJ Prefs --- src/imcflibs/imagej/prefs.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/imcflibs/imagej/prefs.py diff --git a/src/imcflibs/imagej/prefs.py b/src/imcflibs/imagej/prefs.py new file mode 100644 index 0000000..d99412a --- /dev/null +++ b/src/imcflibs/imagej/prefs.py @@ -0,0 +1,19 @@ +"""Functions to work with ImageJ preferences.""" + +from ij import Prefs + +def debug_mode(): + """Wrapper to check if 'imcf.debugging' is enabled. + + This is a workaround for a Jython issue in ImageJ with values that are + stored in the "IJ_Prefs.txt" file being cast to the wrong types and / or + values in Python. Callling Prefs.get() using a (Python) boolean as the + second parameter always leads to the return value '0.0' (Python type float), + no matter what is actually stored in the preferences. Doing the same in e.g. + Groovy behaves correctly. + + Calling Prefs.get() as below with the second parameter being a string and + subsequently checking the string value leads to the expected result. + """ + debug = Prefs.get("imcf.debugging", "false") + return debug == "true" -- GitLab