Beispiel #1
0
def get_config(cfg, path):
    found = None
    for section in cfg.sections():
        try:
            (type, glob) = section.split(None, 1)
        except ValueError:
            continue
        if type != "access":
            continue
        if not match_path.match_path(path=path, glob=glob):
            continue
        if found is None:
            found = {}
        found.update(cfg.items(section))

    return found
Beispiel #2
0
def test_exact():
    assert match_path('foo', 'foo')
Beispiel #3
0
def test_simple_mismatch():
    assert not match_path('foo', 'bar')
Beispiel #4
0
def test_prefix():
    # we want "example.com" to match "example.com/foo"
    assert match_path('foo/bar/baz', 'foo/bar')
    assert not match_path('foo/barbaz', 'foo/bar')
Beispiel #5
0
def test_prefix_wrong_way():
    assert not match_path('foo/bar/baz', 'bar/baz')
Beispiel #6
0
def test_wildcard_matches_slashes():
    assert match_path('foo/bar', 'fo*ar')
Beispiel #7
0
def test_wildcard_partial():
    assert match_path('foobar', 'fo*ar')
Beispiel #8
0
def test_wildcard_full():
    assert match_path('foo', '*')
Beispiel #9
0
def test_exact_dirs():
    assert match_path('foo/bar', 'foo/bar')