From 8c6dba590d30d50372e081c7e52b95f639dea8e5 Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Tue, 10 Oct 2023 10:22:02 +0200 Subject: [PATCH] Minor RF of `get_container_configuration()` Possible a little less complex to understand. --- datalad_container/utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/datalad_container/utils.py b/datalad_container/utils.py index b39dfbef..0a524c3a 100644 --- a/datalad_container/utils.py +++ b/datalad_container/utils.py @@ -47,20 +47,24 @@ def get_container_configuration( If not (matching) container configuration exists, and empty dictionary is returned. """ - # all info is in the dataset config! var_prefix = 'datalad.containers.' + containers = {} + # all info is in the dataset config! for var, value in ds.config.items(): if not var.startswith(var_prefix): # not an interesting variable continue - var_comps = var[len(var_prefix):].split('.') - cname = var_comps[0] + var_comps = var.split('.') + # container name is the 3rd after 'datalad'.'container'. + cname = var_comps[2] if name and name != cname: # we are looking for a specific container's configuration # and this is not it continue - ccfgname = '.'.join(var_comps[1:]) + # reconstruct config item name, anything after + # datalad.containers.. + ccfgname = '.'.join(var_comps[3:]) if not ccfgname: continue