Maintenance will be performed on,,, and on Tuesday 22nd September 2020 starting at approximately 9am MST.It is expected to take around 15 minutes and there will be a short period of downtime towards the end of the maintenance window. Please address any comments, questions, or concerns to

Updating _getCode to be case-insensitive

parent 0cbe3e5e
......@@ -445,18 +445,24 @@ class GraceDb(GsiRest):
return GsiRest.request(self, method, *args, **kwargs)
def _getCode(self, input_value, code_dict):
"""Check if input is valid.
Return coded version if it is"""
# code_dict is dict of { code : descriptive_name }
if input_value in list(code_dict.keys()):
# Already coded
Check if input is valid and return coded version if it is
code_dict is dict of { code : descriptive_name }
# Quick check for simple case where it's already coded
if input_value in code_dict:
return input_value
if not input_value in list(code_dict.values()):
# Not valid
return None
return [code
for code, name in code_dict.items()
if name == input_value][0]
# Loop over code_dict items, if we match either the key or
# value (case-insensitive), return the code.
input_lower = input_value.lower()
for code, display in six.iteritems(code_dict):
if (input_lower == code.lower() or
input_lower == display.lower()):
return code
# Not found, return None
return None
# Search and filecontents are optional when creating an event.
def createEvent(self, group, pipeline, filename, search=None, labels=None,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment