File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 77from .conf import TF_LAYOUT , TF_S3_ROOT , TF_USE_DATALAD
88
99
10- def get (template , ** kwargs ):
10+ def get (template , raise_empty = False , ** kwargs ):
1111 """
1212 Fetch one file from one particular template.
1313
1414 Parameters
1515 ----------
1616 template : str
1717 A template identifier (e.g., ``MNI152NLin2009cAsym``).
18+ raise_empty : bool, optional
19+ Raise exception if no files were matched
1820
1921 Keyword Arguments
2022 -----------------
@@ -50,6 +52,14 @@ def get(template, **kwargs):
5052 ... density='32k', suffix='sphere')) # doctest: +ELLIPSIS
5153 '.../tpl-fsLR_hemi-L_den-32k_sphere.surf.gii'
5254
55+ >>> get('fsLR', space='madeup')
56+ []
57+
58+ >>> get('fsLR', raise_empty=True, space='madeup') # doctest: +IGNORE_EXCEPTION_DETAIL
59+ Traceback (most recent call last):
60+ Exception:
61+ ...
62+
5363 """
5464 out_file = [
5565 Path (p ) for p in TF_LAYOUT .get (template = template , return_type = "file" , ** kwargs )
@@ -93,6 +103,9 @@ def get(template, **kwargs):
93103
94104 raise RuntimeError (msg )
95105
106+ if not out_file and raise_empty :
107+ raise Exception ("No results found" )
108+
96109 if len (out_file ) == 1 :
97110 return out_file [0 ]
98111 return out_file
You can’t perform that action at this time.
0 commit comments