File tree Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -2624,20 +2624,26 @@ def _return_root_paths(
26242624 else :
26252625 if datatype is not None :
26262626 datatype = _ensure_tuple (datatype )
2627- search_str = f"**/{ '|' .join (datatype )} /*.*"
2627+ # If multiple datatypes are provided, search each separately
2628+ # (glob does not support alternation with '|').
2629+ paths = []
2630+ for dt in datatype :
2631+ dt_search = f"**/{ dt } /*.*"
2632+ if ignore_nosub :
2633+ dt_search = f"sub-*/{ dt_search } "
2634+ paths .extend (
2635+ [Path (root , fn ) for fn in glob .iglob (dt_search , root_dir = root , recursive = True )]
2636+ )
26282637 else :
26292638 search_str = "**/*.*"
2630-
2631- # only browse files which are of the form root/sub-*,
2632- # such that we truely only look in 'sub'-folders:
2633- if ignore_nosub :
2634- search_str = f"sub-*/{ search_str } "
2635- # TODO: Why is this not equivalent to list(root.rglob(search_str)) ?
2636- # Most of the speedup is from using glob.iglob here.
2637- paths = [
2638- Path (root , fn )
2639- for fn in glob .iglob (search_str , root_dir = root , recursive = True )
2640- ]
2639+ if ignore_nosub :
2640+ search_str = f"sub-*/{ search_str } "
2641+ # TODO: Why is this not equivalent to list(root.rglob(search_str)) ?
2642+ # Most of the speedup is from using glob.iglob here.
2643+ paths = [
2644+ Path (root , fn )
2645+ for fn in glob .iglob (search_str , root_dir = root , recursive = True )
2646+ ]
26412647
26422648 return _filter_paths_optimized (paths , ignore_json )
26432649
You can’t perform that action at this time.
0 commit comments