11import fnmatch
22import re
3+ import itertools
34
45from .. import config
56from ..types import Origin
3334# 'value': '*.dcm'
3435# },
3536# {
36- # 'type': 'file.measurements ', # Match any of the file's measurements
37+ # 'type': 'file.classification ', # Match any of the file's classification
3738# 'value': 'diffusion'
3839# },
3940# {
4041# 'type': 'container.has-type', # Match the container having any file (including this one) with this type
4142# 'value': 'bvec'
4243# },
4344# {
44- # 'type': 'container.has-measurement ', # Match the container having any file (including this one) with this measurement
45+ # 'type': 'container.has-classification ', # Match the container having any file (including this one) with this classification
4546# 'value': 'functional'
4647# }
4748# ]
@@ -86,10 +87,11 @@ def match(value):
8687 elif match_type == 'file.name' :
8788 return match (file_ ['name' ])
8889
89- # Match any of the file's measurements
90- elif match_type == 'file.measurements ' :
90+ # Match any of the file's classification
91+ elif match_type == 'file.classification ' :
9192 if match_param :
92- return any (match (value ) for value in file_ .get ('measurements' , []))
93+ classification_values = list (itertools .chain .from_iterable (file_ .get ('classification' , {}).itervalues ()))
94+ return any (match (value ) for value in classification_values )
9395 else :
9496 return False
9597
@@ -102,11 +104,12 @@ def match(value):
102104
103105 return False
104106
105- # Match the container having any file (including this one) with this measurement
106- elif match_type == 'container.has-measurement ' :
107+ # Match the container having any file (including this one) with this classification
108+ elif match_type == 'container.has-classification ' :
107109 if match_param :
108110 for c_file in container ['files' ]:
109- if any (match (value ) for value in c_file .get ('measurements' , [])):
111+ classification_values = list (itertools .chain .from_iterable (c_file .get ('classification' , {}).itervalues ()))
112+ if any (match (value ) for value in classification_values ):
110113 return True
111114
112115 return False
0 commit comments