fixed bug for only blacklisting.
This commit is contained in:
parent
9d5ca8b631
commit
54746c85d3
|
@ -60,17 +60,16 @@ for name in filenames:
|
|||
labels.append(label) # remember name...
|
||||
positions.append(position) # ...and position
|
||||
|
||||
order = []
|
||||
for label in labels: # check each selected label
|
||||
match = [fnmatch.fnmatch(label,needle) for needle in options.whitelist] # which whitelist items do match it
|
||||
order.append(match.index(True) if np.sum(match) == 1 else -1) # unique match --> store which
|
||||
if options.whitelist != None and options.blacklist == None: # check whether reordering is possible
|
||||
position = np.zeros(len(labels))
|
||||
for i,label in enumerate(labels): # check each selected label
|
||||
match = [fnmatch.fnmatch(label,needle) for needle in options.whitelist] # which whitelist items do match it
|
||||
position[i] = match.index(True) if np.sum(match) == 1 else -1 # unique match --> store which
|
||||
|
||||
if options.blacklist != None or np.any(order < 0): # have blacklist or non-unique matching?
|
||||
order = range(len(order)) # skip reordering
|
||||
|
||||
reorder = np.zeros(len(order),dtype=int)
|
||||
for i in xrange(len(order)):
|
||||
reorder[order[i]] = i
|
||||
sorted = np.argsort(position)
|
||||
order = range(len(labels)) if sorted[0] < 0 else sorted # skip reordering if non-unique, i.e. first sorted is "-1"
|
||||
else:
|
||||
order = range(len(labels)) # maintain original order of labels
|
||||
|
||||
interpolator = []
|
||||
condition = options.condition # copy per file, might be altered
|
||||
|
@ -91,11 +90,11 @@ for name in filenames:
|
|||
evaluator = "'" + condition + "'.format(" + ','.join(interpolator) + ")"
|
||||
|
||||
# ------------------------------------------ assemble header ---------------------------------------
|
||||
table.labels = np.array(labels)[reorder] # update with new label set
|
||||
table.labels = np.array(labels)[order] # update with new label set
|
||||
table.head_write()
|
||||
|
||||
# ------------------------------------------ process data ------------------------------------------
|
||||
positions = np.array(positions)[reorder]
|
||||
positions = np.array(positions)[order]
|
||||
outputAlive = True
|
||||
while outputAlive and table.data_read(): # read next data line of ASCII table
|
||||
specials['_row_'] += 1 # count row
|
||||
|
|
Loading…
Reference in New Issue