From 684e29367c4e1eeb786a14e1ecc8557397283457 Mon Sep 17 00:00:00 2001 From: Marcel Zwiers Date: Tue, 13 Feb 2024 12:07:46 +0100 Subject: [PATCH] First read the path to the config file from the environment (Github issue #226) --- bidscoin/__init__.py | 8 ++++---- bidscoin/cli/_bcoin.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bidscoin/__init__.py b/bidscoin/__init__.py index f900bb75..6f329cdc 100644 --- a/bidscoin/__init__.py +++ b/bidscoin/__init__.py @@ -58,8 +58,11 @@ schemafolder = bidscoinroot/'schema' pluginfolder = bidscoinroot/'plugins' +# Get the BIDSCOIN_DEBUG environment variable to set the log-messages and logging level, etc +DEBUG = platform.os.getenv('BIDSCOIN_DEBUG','').upper() in ('1', 'TRUE', 'Y', 'YES') + # Create a BIDScoin user configuration directory if needed and load the BIDScoin user settings -configfile = Path.home()/'.bidscoin'/__version__/'config.toml' +configfile = platform.os.getenv('BIDSCOIN_CONFIG', Path.home()/'.bidscoin'/__version__/'config.toml') templatefolder = configfile.parent/'templates' templatefolder.mkdir(parents=True, exist_ok=True) if not configfile.is_file(): @@ -77,9 +80,6 @@ if not bidsmap_template.is_file(): warnings.warn(f"Missing template bidsmap: {bidsmap_template} (see {configfile})", RuntimeWarning) -# Get the BIDSCOIN_DEBUG environment variable to set the log-messages and logging level, etc -DEBUG = platform.os.getenv('BIDSCOIN_DEBUG','').upper() in ('1', 'TRUE', 'Y', 'YES') - # Register the BIDScoin citation due.cite(Doi('10.3389/fninf.2021.770608'), description='A versatile toolkit to convert source data to the Brain Imaging Data Structure (BIDS)', path='bidscoin', version=__version__, cite_module=True, tags=['reference-implementation']) diff --git a/bidscoin/cli/_bcoin.py b/bidscoin/cli/_bcoin.py index 98a7ef4b..8e61129d 100755 --- a/bidscoin/cli/_bcoin.py +++ b/bidscoin/cli/_bcoin.py @@ -10,7 +10,8 @@ Default settings and template bidsmaps are stored in the ".bidscoin" folder in your home directory (you can modify them to your needs with any plain text editor) -Set the environment variable BIDSCOIN_DEBUG=TRUE to run BIDScoin in a more verbose logging mode. +Set the environment variable BIDSCOIN_DEBUG=TRUE to run BIDScoin in a more verbose logging mode and +BIDSCOIN_CONFIG=/writable/path/to/config.toml if you like to use a different config file. Citation reports can be generated with the help of duecredit (https://github.com/duecredit/duecredit) For more documentation see: https://bidscoin.readthedocs.io