Beispiel #1
0
def parse_group_order(inp, query, qfield, parse_singleton=int):
    if LIST_RE.match(inp):
        collapse_ors(parse_range2_extend(inp, qfield, parse_singleton), query)
    else:
        raise ValueError("It needs to be an integer (such as 25), \
                    a range of integers (such as 2-10 or 2..10), \
                    a linear function of variable g for genus (such as 84(g-1), 84g-84, 84g, or g-1), \
                    or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121).")
Beispiel #2
0
def parse_substring(info, query, field, qfields, start="%", end="%"):
    if info.get(field):
        kwds = [elt.strip() for elt in info.get(field).split(",") if elt.strip()]
        collapse_ors(
            [
                "$or",
                [{qfield: {"$ilike": start + elt + end}} for elt in kwds for qfield in qfields],
            ],
            query,
        )