From 9e30e98e905e80f85f198e17ea6cc10c539233cc Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Mon, 23 Sep 2024 13:52:49 +0300 Subject: [PATCH] fix: allow colon in options interpolation --- src/ahriman/core/configuration/shell_interpolator.py | 2 +- .../ahriman/core/configuration/test_shell_interpolator.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ahriman/core/configuration/shell_interpolator.py b/src/ahriman/core/configuration/shell_interpolator.py index d2f35576..7663d091 100644 --- a/src/ahriman/core/configuration/shell_interpolator.py +++ b/src/ahriman/core/configuration/shell_interpolator.py @@ -52,7 +52,7 @@ class ShellInterpolator(configparser.Interpolation): def identifiers() -> Generator[tuple[str | None, str], None, None]: # extract all found identifiers and parse them for identifier in ShellTemplate(value).get_identifiers(): - match identifier.split(":"): + match identifier.rsplit(":", maxsplit=1): case [lookup_option]: # single option from the same section yield None, lookup_option case [lookup_section, lookup_option]: # reference to another section diff --git a/tests/ahriman/core/configuration/test_shell_interpolator.py b/tests/ahriman/core/configuration/test_shell_interpolator.py index 24b36b3f..7cfa4dc9 100644 --- a/tests/ahriman/core/configuration/test_shell_interpolator.py +++ b/tests/ahriman/core/configuration/test_shell_interpolator.py @@ -24,6 +24,9 @@ def _parser() -> dict[str, dict[str, str]]: "key3": "${section1:home}", "key5": "${section1:key4}", }, + "section4:suffix": { + "key6": "value6" + }, } @@ -45,6 +48,10 @@ def test_extract_variables() -> None: assert not dict(ShellInterpolator._extract_variables(parser, "${section4:key1}", parser["section1"])) + assert dict(ShellInterpolator._extract_variables(parser, "${section4:suffix:key6}", parser["section1"])) == { + "section4:suffix:key6": "value6", + } + def test_environment() -> None: """