diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2010-07-23 18:45:12 +0000 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2010-07-30 11:53:15 -0500 |
commit | 14546a375ce7b2830675ba1d64f83e06dc3bdd91 (patch) | |
tree | 1862bae64e27873bbe187000596f4693c1dbc9e3 /src/lib | |
parent | f072f3b85524ec80e537cdf9f3dc966c90119981 (diff) | |
download | bcfg2-14546a375ce7b2830675ba1d64f83e06dc3bdd91.tar.gz bcfg2-14546a375ce7b2830675ba1d64f83e06dc3bdd91.tar.bz2 bcfg2-14546a375ce7b2830675ba1d64f83e06dc3bdd91.zip |
Commit whitelist/blacksupport for glob style entries
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5986 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Client/Frame.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/lib/Client/Frame.py b/src/lib/Client/Frame.py index 7d6f6b475..6cfb19732 100644 --- a/src/lib/Client/Frame.py +++ b/src/lib/Client/Frame.py @@ -35,15 +35,28 @@ def promptFilter(prompt, entries): continue return ret +def matches_entry(entryspec, entry): + # both are (tag, name) + if entryspec == entry: + return True + else: + for i in [0, 1]: + if entryspec[i] == entry[i]: + continue + elif entryspec[i] == '*': + continue + elif '*' in entryspec[i]: + starpt = entryspec[i].index('*') + if entry[i].startswith(entryspec[i][:starpt]): + continue + return False + return True + def matches_white_list(entry, whitelist): - return [entry.tag, entry.get('name')] in whitelist or \ - [entry.tag, '*'] in whitelist or \ - ['*', entry.get('name')] in whitelist + return True in [matches_entry(we, (entry.tag, entry.get('name'))) for we in whitelist] def passes_black_list(entry, blacklist): - return [entry.tag, entry.get('name')] not in blacklist and \ - [entry.tag, '*'] not in blacklist and \ - ['*', entry.get('name')] not in blacklist + return True not in [matches_entry(be, (entry.tag, entry.get('name'))) for be in blacklist] class Frame: """Frame is the container for all Tool objects and state information.""" |