Ejemplo n.º 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
Ejemplo n.º 2
0
def test_exact():
    assert match_path('foo', 'foo')
Ejemplo n.º 3
0
def test_simple_mismatch():
    assert not match_path('foo', 'bar')
Ejemplo n.º 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')
Ejemplo n.º 5
0
def test_prefix_wrong_way():
    assert not match_path('foo/bar/baz', 'bar/baz')
Ejemplo n.º 6
0
def test_wildcard_matches_slashes():
    assert match_path('foo/bar', 'fo*ar')
Ejemplo n.º 7
0
def test_wildcard_partial():
    assert match_path('foobar', 'fo*ar')
Ejemplo n.º 8
0
def test_wildcard_full():
    assert match_path('foo', '*')
Ejemplo n.º 9
0
def test_exact_dirs():
    assert match_path('foo/bar', 'foo/bar')