diff --git a/CHANGELOG.md b/CHANGELOG.md index d72aaa8539bbc3dbe6d3b90b819b73f87e0aba1f..69d0c4e2b125803ccec7225c604c07f17fc68645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### +* [93](https://gitlab.com/linkahead/linkahead-crawler/-/issues/93) cfood.yaml does not allow umlaut in $expression + ### Security ### ### Documentation ### diff --git a/src/caoscrawler/converters.py b/src/caoscrawler/converters.py index 296bfeedfe8fcf325304bb84ddbb236bb5a0bf30..285d4cccb8780b400caf806122c4f4c787db7aeb 100644 --- a/src/caoscrawler/converters.py +++ b/src/caoscrawler/converters.py @@ -52,7 +52,7 @@ from .utils import has_parent # by the converters: SPECIAL_PROPERTIES = ("description", "name", "id", "path", "file", "checksum", "size") -SINGLE_VAR_RE = re.compile(r"^\$(\{)?(?P<varname>[0-9a-zA-Z_]+)(\})?$") +SINGLE_VAR_RE = re.compile(r"^\$(\{)?(?P<varname>\w+)(\})?$") logger = logging.getLogger(__name__) diff --git a/unittests/test_issues.py b/unittests/test_issues.py index cbbe9cabcfd17daaf07165757351f00dc051eeab..f123fb822c8cbc8d4bef14c3e6f9671a7aa429db 100644 --- a/unittests/test_issues.py +++ b/unittests/test_issues.py @@ -22,13 +22,11 @@ from pytest import mark -import caosdb as db - +from caoscrawler.converters import replace_variables from caoscrawler.crawl import Crawler -from caoscrawler.identifiable import Identifiable -from caoscrawler.identifiable_adapters import CaosDBIdentifiableAdapter -from caoscrawler.structure_elements import DictElement +from caoscrawler.structure_elements import DictElement +from caoscrawler.stores import GeneralStore from caoscrawler.scanner import create_converter_registry, scan_structure_elements @@ -110,3 +108,19 @@ def test_list_datatypes(): assert isinstance(records[0].get_property("Subject").value, list) assert records[0].get_property("Subject").datatype is not None assert records[0].get_property("Subject").datatype.startswith("LIST") + + +def test_issue_93(): + """https://gitlab.com/linkahead/linkahead-crawler/-/issues/93 + + cfood.yaml does not allow umlaut in $expression""" + values = GeneralStore() + expressions = [ + "1", + "Ä", + "ųøîµ", + ] + for exp in expressions: + values[exp] = f"This is {exp}" + for exp in expressions: + assert replace_variables(f"${exp}", values) == f"This is {exp}"