Пример #1
0
def do_filter2(result, text):
    comparator = get_comparator(text)
    if comparator:
        text = split_and_strip(text, comparator)

    context = dict(result=result)
    value = parse_dollar(context, text)
    # filter_result = eval(str(text), {}, context)
    # if is_expr(text):
    #     assert eval(text, {}, dict(result=result))
    #     return result
    return text
Пример #2
0
def parse_args(context: dict, *args):
    return [parse_dollar(context, arg) for arg in args]
Пример #3
0
def parse_kwargs(context: dict, **kwargs):
    return {
        parse_dollar(context, key): parse_dollar(context, value)
        for key, value in kwargs.items()
    }
Пример #4
0
def test_util_parse():
    context = {'a': 1}
    assert parse_dollar(context, 'hello,$a') == 'hello,1'