Skip to content

Commit 2a49275

Browse files
committed
fix(config): migrated dot marker to _DOT_
1 parent 1e77ea4 commit 2a49275

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

servc/svc/config/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"conf.bus.bindtoeventexchange": True,
2121
}
2222

23+
DOT_MARKER = os.getenv("SERVC_DOT_MARKER", "_DOT_")
24+
2325

2426
class Config:
2527
_configDictionary: dict = {}
@@ -59,7 +61,7 @@ def __init__(self, config_path: str | None = None):
5961
raise Exception("Configuration file does not match the configuration path")
6062

6163
def get(self, key: str) -> Any:
62-
keys = [x.replace("--", ".") for x in key.lower().split(".")]
64+
keys = [x.replace(DOT_MARKER, ".") for x in key.split(".")]
6365
subconfig = self._configDictionary
6466

6567
for index, subkey in enumerate(keys):
@@ -71,7 +73,7 @@ def get(self, key: str) -> Any:
7173
subconfig = subconfig.get(subkey, {})
7274

7375
def setValue(self, key: str, value: Any):
74-
keys = [x.replace("--", ".") for x in key.lower().split(".")]
76+
keys = [x.replace(DOT_MARKER, ".") for x in key.split(".")]
7577
subconfig = self._configDictionary
7678

7779
for index, subkey in enumerate(keys):

tests/svc/test_config.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ def test_value(self):
1818
self.assertEqual(self.config.get("conf.bus.prefix"), "test")
1919

2020
self.config.setValue("conf.bus.routemap.api", "test_route")
21-
self.assertEqual(self.config.get(
22-
"conf.bus.routemap.api"), "test_route")
21+
self.assertEqual(self.config.get("conf.bus.routemap.api"), "test_route")
2322

24-
self.config.setValue("conf.bus.routemap--api", "test_route")
25-
self.assertEqual(self.config.get(
26-
"conf.bus.routemap--api"), "test_route")
27-
self.assertIn("routemap.api", self.config.get('conf.bus'))
23+
self.config.setValue("conf.bus.routemap_DOT_api", "test_route")
24+
self.assertEqual(self.config.get("conf.bus.routemap_DOT_api"), "test_route")
25+
self.assertIn("routemap.api", self.config.get("conf.bus"))
2826

2927
def test_wrong_location(self):
3028
try:

0 commit comments

Comments
 (0)