added wildcard matching ( "?", "*", "[(!)sequence_of_characters]" ) for ASCII table labels

This commit is contained in:
Philip Eisenlohr 2012-11-29 10:42:13 +00:00
parent 7358dd6679
commit f446d4d87e
1 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import os,re,sys,math,string,damask import os,re,sys,fnmatch,math,string,damask
from optparse import OptionParser, Option from optparse import OptionParser, Option
# ----------------------------- # -----------------------------
@ -76,8 +76,8 @@ for file in files:
labels = [] labels = []
positions = [] positions = []
for position,label in enumerate(table.labels): for position,label in enumerate(table.labels):
if (options.whitelist == [] or label in options.whitelist) \ if (options.whitelist == [] or any([fnmatch.fnmatch(label,needle) for needle in options.whitelist])) \
and (options.blacklist == [] or label not in options.blacklist): # a label to keep? and (options.blacklist == [] or not any([fnmatch.fnmatch(label,needle) for needle in options.blacklist])): # a label to keep?
labels.append(label) # remember name... labels.append(label) # remember name...
positions.append(position) # ...and position positions.append(position) # ...and position