[docs]classQueryType(Enum):""" SimDB query comparator options. """NONE=auto()EQ=auto()# EqualNE=auto()# Not EqualIN=auto()# ContainingNI=auto()# Not containingGT=auto()# Greater thanGE=auto()# Greater than or equalLT=auto()# Less thanLE=auto()# Less than or equalAGT=auto()# Any greater thanAGE=auto()# Any greater than or equalALT=auto()# Any less thanALE=auto()# Any less than or equalEXIST=auto()
[docs]defparse_query_arg(value:str)->Tuple[str,QueryType]:""" Parse the second half of a SimDB query argument and return the comparator type and value to be compared. The strings being parsed will be of the form: value comparator:value If no comparator is given then QueryType.EQ is returned as a default. :param value: The query string to parse. :return: The extracted value and comparator. """ifnotvalue:returnvalue,QueryType.NONE*comp,value=value.split(":")ifnotcomp:returnvalue,QueryType.EQiflen(comp)>1:raiseValueError(f"Malformed query string {value}.")fromNonetry:returnvalue,QueryType[comp[0].upper()]exceptKeyError:raiseValueError(f"Unknown query modifier {comp[0]}.")fromNone