From f6074ee04057769ebb6b9a86c2187ee6a484f850 Mon Sep 17 00:00:00 2001 From: zrgt Date: Wed, 15 Nov 2023 19:44:36 +0100 Subject: [PATCH] Soften the language tag constraint remove constraint, that if the second part of lang tag exists, it must be a region See https://github.com/eclipse-basyx/basyx-python-sdk/issues/157 --- basyx/aas/model/base.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/basyx/aas/model/base.py b/basyx/aas/model/base.py index 9bc2386b1..dc3079625 100644 --- a/basyx/aas/model/base.py +++ b/basyx/aas/model/base.py @@ -288,12 +288,10 @@ def __init__(self, dict_: Dict[str, str]): @classmethod def _check_language_tag_constraints(cls, ltag: str): split = ltag.split("-", 1) - if len(split[0]) != 2 or not split[0].isalpha() or not split[0].islower(): - raise ValueError(f"The language code '{split[0]}' of the language tag '{ltag}' doesn't consist of exactly " - "two lower-case letters!") - if len(split) > 1 and (len(split[1]) != 2 or not split[1].isalpha() or not split[1].isupper()): - raise ValueError(f"The extension '{split[1]}' of the language tag '{ltag}' doesn't consist of exactly " - "two upper-case letters!") + lang_code = split[0] + if len(lang_code) != 2 or not lang_code.isalpha() or not lang_code.islower(): + raise ValueError(f"The language code of the language tag must consist of exactly two lower-case letters! " + f"Given language tag and language code: '{ltag}', '{lang_code}'") def __getitem__(self, item: str) -> str: return self._dict[item]