Skip to content

Commit

Permalink
Minor RF of get_container_configuration()
Browse files Browse the repository at this point in the history
Possible a little less complex to understand.
  • Loading branch information
mih committed Oct 10, 2023
1 parent 8499756 commit 7643b4a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions datalad_container/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 2rd after 'datalad'.'container'.

Check failure on line 59 in datalad_container/utils.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

2rd ==> 2nd
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.<name>.
ccfgname = '.'.join(var_comps[3:])
if not ccfgname:
continue

Expand Down

0 comments on commit 7643b4a

Please sign in to comment.