Skip to content
Snippets Groups Projects
Commit 6b5b7d2f authored by Priest's avatar Priest
Browse files

Added missing parameter must_exist to get_key_value and modified sys.exit of...

Added missing parameter must_exist to get_key_value and modified sys.exit of same function to properly display the missing key and dictionary
parent ee1a8309
No related branches found
No related tags found
No related merge requests found
...@@ -332,12 +332,12 @@ class CommonDictFile: ...@@ -332,12 +332,12 @@ class CommonDictFile:
key_values.append(None) key_values.append(None)
return cm.unlistify(key_values) return cm.unlistify(key_values)
def get_key_value(self, key, the_dict): def get_key_value(self, key, the_dict, must_exist=False):
"""Get the value of a key from a single dict, or None in case the key does not exist, or exit if the key must exist.""" """Get the value of a key from a single dict, or None in case the key does not exist, or exit if the key must exist."""
if key in the_dict: if key in the_dict:
key_value = the_dict[key] key_value = the_dict[key]
elif must_exist: elif must_exist:
sys.exit('Error : Key %s does not exist in the dictionary:\n%s.' % (key, fd)) sys.exit('Error : Key %s does not exist in the dictionary:\n%s.' % (key, the_dict))
else: else:
key_value = None key_value = None
return key_value return key_value
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment