Пример #1
0
def AssertNot(expression):
    return Expression.Assert(expression, invert=1)
Пример #2
0
        return Expression.AtBeginning()
    elif where == "at_end":
        return Expression.AtEnd()
    raise AssertionError("Unknown at name: %s" % repr(where))


# Convert an 'any' tuple into a Dot object
def convert_any(group_names, name, ignore):
    assert ignore is None, "what does it mean when the field is '%s'?" % ignore
    return Expression.Dot()


# Convert an 'assert' tuple into a Assert object, as a positive assertion
def convert_assert(group_names, name, (direction, terms)):
    assert direction == 1, "does not support lookbehind"
    return Expression.Assert(convert_list(group_names, terms), 0)


# Convert an 'assert_not' tuple into a Assert object, as a negative assertion
def convert_assert_not(group_names, name, (direction, terms)):
    assert direction == 1, "does not support lookbehind"
    return Expression.Assert(convert_list(group_names, terms), 1)


# Convert a 'branch' tuple into an Alt object
def convert_branch(group_names, name, (ignore, branches)):
    assert ignore is None, "what is %s?" % repr(ignore)
    results = []
    for branch in branches:
        results.append(convert_list(group_names, branch))
    if len(results) == 1:
Пример #3
0
def Assert(expression):
    return Expression.Assert(expression)