Пример #1
0
def partition_raw_only_range(range):
    parts = EX_ONLY_RANGE_REGEXP.search(range).groups()
    if parts[-1]:
        return EX_RANGE(
                    left=parts[-1],
                    left_offset='0',
                    separator='',
                    right='',
                    right_offset='0'
                    )
    else:
        return EX_RANGE(
                    left=parts[0],
                    left_offset=parts[1] or '0',
                    separator=parts[2],
                    right=parts[3],
                    right_offset=parts[4] or '0',
                    )
Пример #2
0
def test_is_only_range_regexp():
    assert EX_ONLY_RANGE_REGEXP.search('/foo').groups() == (None, None, None, None, None, '/foo') 
    assert EX_ONLY_RANGE_REGEXP.search('/foo bar').groups() == (None, None, None, None, None, '/foo bar') 
    assert EX_ONLY_RANGE_REGEXP.search('?foo').groups() == (None, None, None, None, None, '?foo')
    assert EX_ONLY_RANGE_REGEXP.search('?foo bar').groups() == (None, None, None, None, None, '?foo bar')

    assert EX_ONLY_RANGE_REGEXP.search('/foo/').groups() == ('/foo/', None, None, None, None, None)
    assert EX_ONLY_RANGE_REGEXP.search('?foo?').groups() == ('?foo?', None, None, None, None, None)

    assert EX_ONLY_RANGE_REGEXP.search('/foo/+10').groups() == ('/foo/', '+10', None, None, None, None)
    assert EX_ONLY_RANGE_REGEXP.search('?foo?+10').groups() == ('?foo?', '+10', None, None, None, None)

    assert EX_ONLY_RANGE_REGEXP.search('.').groups() == ('.', None, None, None, None, None)
    assert EX_ONLY_RANGE_REGEXP.search('%').groups() == ('%', None, None, None, None, None)
    assert EX_ONLY_RANGE_REGEXP.search('$').groups() == ('$', None, None, None, None, None)

    assert EX_ONLY_RANGE_REGEXP.search('0').groups() == ('0', None, None, None, None, None)
    assert EX_ONLY_RANGE_REGEXP.search('100').groups() == ('100', None, None, None, None, None)

    assert EX_ONLY_RANGE_REGEXP.search('.,.').groups() == ('.', None, ',', '.', None, None)
    assert EX_ONLY_RANGE_REGEXP.search('.,$').groups() == ('.', None, ',', '$', None, None)
    assert EX_ONLY_RANGE_REGEXP.search('$,.').groups() == ('$', None, ',', '.', None, None)

    assert EX_ONLY_RANGE_REGEXP.search('.+10,$-5').groups() == ('.', '+10', ',', '$', '-5', None)
    assert EX_ONLY_RANGE_REGEXP.search('/foo/+10,$-5').groups() == ('/foo/', '+10', ',', '$', '-5', None)

    assert EX_ONLY_RANGE_REGEXP.search(r'/foo\//').groups() == (r'/foo\//', None, None, None, None, None)