Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org 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 computing-help@igwn.org.

Updating _getCode to be case-insensitive

parent 0cbe3e5e
...@@ -445,18 +445,24 @@ class GraceDb(GsiRest): ...@@ -445,18 +445,24 @@ class GraceDb(GsiRest):
return GsiRest.request(self, method, *args, **kwargs) return GsiRest.request(self, method, *args, **kwargs)
def _getCode(self, input_value, code_dict): def _getCode(self, input_value, code_dict):
"""Check if input is valid. """
Return coded version if it is""" Check if input is valid and return coded version if it is
# code_dict is dict of { code : descriptive_name } code_dict is dict of { code : descriptive_name }
if input_value in list(code_dict.keys()): """
# Already coded # Quick check for simple case where it's already coded
if input_value in code_dict:
return input_value return input_value
if not input_value in list(code_dict.values()):
# Not valid # Loop over code_dict items, if we match either the key or
return None # value (case-insensitive), return the code.
return [code input_lower = input_value.lower()
for code, name in code_dict.items() for code, display in six.iteritems(code_dict):
if name == input_value][0] 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. # Search and filecontents are optional when creating an event.
def createEvent(self, group, pipeline, filename, search=None, labels=None, 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