Skip to content

Commit 8772cd1

Browse files
Martin Roylindycoder
authored andcommitted
Support absolute paths
Fixes #16
1 parent e28796f commit 8772cd1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

config_probe/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def probe(path, patterns):
1818

1919
glob_pattern = pattern.replace(NAMESPACE_PLACEHOLDER, "*")
2020
for config_file in glob.glob(os.path.join(path, glob_pattern)):
21-
relevant_part_of_the_path = config_file[len(path) + 1:]
21+
relevant_part_of_the_path = config_file if os.path.isabs(pattern) else config_file[len(path) + 1:]
2222
path_parts, ext = os.path.splitext(relevant_part_of_the_path)
2323
path_matchers, _ = os.path.splitext(pattern)
2424

tests/test_config_probe.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ def test_dict_should_behave_as_dict(self):
111111
def test_support_for_empty_files(self):
112112
probe(path=_dir("empty-files"), patterns=["*.*"])
113113

114+
def test_support_absolute_paths_outside_base_dir(self):
115+
config = probe(path=_dir("single-file-with-namespace"), patterns=[
116+
"{}/(*)/(*)/stuff.yaml".format(os.path.dirname(__file__))
117+
])
118+
assert_that(config['two-files-with-subdir-namespace'].ns1.key1, is_("stuff from ns1"))
119+
assert_that(config['two-files-with-subdir-namespace'].ns2.key2, is_("stuff from ns2"))
120+
114121
def test_fake_probe(self):
115122
config = fake_probe({
116123
"key": "value",

0 commit comments

Comments
 (0)