From 2acfcc871fbf877dc18140510c8b66e88c56a483 Mon Sep 17 00:00:00 2001 From: Piotr Dec Date: Thu, 11 Jun 2026 16:50:48 +0200 Subject: [PATCH] fix: dash in identifiers --- src/karl/services/mo.py | 2 +- tests/files/test1/test.mo.env | 3 +++ tests/test_mo_env.py | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/karl/services/mo.py b/src/karl/services/mo.py index c063d62..e0b1388 100644 --- a/src/karl/services/mo.py +++ b/src/karl/services/mo.py @@ -9,7 +9,7 @@ from karl.services import Passwords class ValueTemplate(Template): # Pozwala na kropki i ukośniki w nazwach placeholderów, np. ${user.name/first} - idpattern = r'[_a-zA-Z][_a-zA-Z0-9.\/]*' + idpattern = r'[_a-zA-Z][_a-zA-Z0-9.\/\-]*' @injectable diff --git a/tests/files/test1/test.mo.env b/tests/files/test1/test.mo.env index e3b4cb0..cbdde2f 100644 --- a/tests/files/test1/test.mo.env +++ b/tests/files/test1/test.mo.env @@ -5,3 +5,6 @@ custom=${custom.field} uname=${sample.username} invalid=${double.dot.example} + +#some comment +dashed=${some/dashed} diff --git a/tests/test_mo_env.py b/tests/test_mo_env.py index bbbf0da..b5e26a7 100644 --- a/tests/test_mo_env.py +++ b/tests/test_mo_env.py @@ -1,7 +1,6 @@ from pathlib import Path import pytest -import yaml from karl.services import Passwords from karl.services.mo import Mo @@ -31,11 +30,10 @@ def test1_content(target_path: Path): content = target_path.read_text() assert '${' not in content - props = {} prop_lines = content.split('\n') for line in prop_lines: - if len(line)> 1: + if len(line) > 1 and not line.startswith("#"): splitted = line.split('=') props[splitted[0]] = splitted[1] # props = {prop[0]:prop[1] for prop in content.split('\n')} @@ -54,6 +52,9 @@ class TestEnvParsing: def test_mixed(self, test1_content: dict): assert test1_content['mixed'] == 'nested_username' + def test_dashed(self, test1_content: dict): + assert test1_content['dashed'] == 'dd-value' + def test_custom_field(self, test1_content: dict): assert test1_content['custom'] == 'custom_content'