Пример #1
0
def test_try_match(regexps, string, expected):
    regexps = re.compile(regexps) if isinstance(regexps, str) else list(map(re.compile, regexps))
    match = util.try_match(regexps, string)
    if not expected:
        assert match is None
    elif isinstance(expected, str):
        assert match.groups()[0] == expected
    else:
        assert match is not None
Пример #2
0
def _parse_line(line, regexps):
    match = try_match(regexps, line)
    return match.groupdict() if match is not None else None