Skip to content
Snippets Groups Projects
Commit 8c2549f8 authored by Nathaniel Kofalt's avatar Nathaniel Kofalt
Browse files

Tolerate optional file keys

parent b54eaced
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,9 @@ HARDCODED_RULES = [
}
]
def _log_file_key_error(file_, container, error):
log.warning('file ' + file_['name'] + ' in container ' + str(container['_id']) + ' ' + error)
def eval_match(match_type, match_param, file_, container):
"""
Given a match entry, return if the match succeeded.
......@@ -61,7 +64,11 @@ def eval_match(match_type, match_param, file_, container):
# Match the file's type
if match_type == 'file.type':
return file_['type'] == match_param
try:
return file_['type'] == match_param
except KeyError:
_log_file_key_error(file_, container, 'has no type key')
return False
# Match a shell glob for the file name
elif match_type == 'file.name':
......@@ -69,7 +76,11 @@ def eval_match(match_type, match_param, file_, container):
# Match any of the file's measurements
elif match_type == 'file.measurements':
return match_param in file_[measurements]
try:
return match_param in file_[measurements]
except KeyError:
_log_file_key_error(file_, container, 'has no measurements key')
return False
# Match the container's primary measurment
elif match_type == 'container.measurement':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment