def get_inverse_dictionary(dataDict, field, srcdir): """ Create a dictionary with the values of field as the keys, and the name of the tests as the results. """ invDict = {} if field == 'name': invDict['name'] = [] for root in dataDict: for exfile in dataDict[root]: for test in dataDict[root][exfile]: if test in testparse.buildkeys: continue defroot = testparse.getDefaultOutputFileRoot(test) name = nameSpace(defroot, os.path.relpath(root, srcdir)) if field == 'name': invDict['name'].append(name) continue if field not in dataDict[root][exfile][test]: continue values = dataDict[root][exfile][test][field] for val in values.split(): if val in invDict: invDict[val].append(name) else: invDict[val] = [name] return invDict
def get_inverse_dictionary(dataDict,fields,srcdir): """ Create a dictionary with the values of field as the keys, and the name of the tests as the results. """ invDict={} # Comma-delimited lists denote union for field in fields.replace('|',',').split(','): if field not in invDict: if field == 'name': invDict[field]=[] # List for ease else: invDict[field]={} for root in dataDict: for exfile in dataDict[root]: for test in dataDict[root][exfile]: if test in testparse.buildkeys: continue defroot = testparse.getDefaultOutputFileRoot(test) fname=nameSpace(defroot,os.path.relpath(root,srcdir)) if field == 'name': invDict['name'].append(fname) continue if field not in dataDict[root][exfile][test]: continue values=dataDict[root][exfile][test][field] if not field == 'args' and not field == 'diff_args': for val in values.split(): if val in invDict[field]: invDict[field][val].append(fname) else: invDict[field][val] = [fname] else: # Args are funky. for varset in re.split('(^|\W)-(?=[a-zA-Z])',values): val=get_value(varset) if not val: continue if val in invDict[field]: invDict[field][val].append(fname) else: invDict[field][val] = [fname] # remove duplicate entries (multiple test/file) if not field == 'name': for val in invDict[field]: invDict[field][val]=list(set(invDict[field][val])) return invDict