예제 #1
0
파일: get_config.py 프로젝트: tv42/sekrit
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
예제 #2
0
def test_exact():
    assert match_path('foo', 'foo')
예제 #3
0
def test_simple_mismatch():
    assert not match_path('foo', 'bar')
예제 #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')
예제 #5
0
def test_prefix_wrong_way():
    assert not match_path('foo/bar/baz', 'bar/baz')
예제 #6
0
def test_wildcard_matches_slashes():
    assert match_path('foo/bar', 'fo*ar')
예제 #7
0
def test_wildcard_partial():
    assert match_path('foobar', 'fo*ar')
예제 #8
0
def test_wildcard_full():
    assert match_path('foo', '*')
예제 #9
0
def test_exact_dirs():
    assert match_path('foo/bar', 'foo/bar')