Skip to content

Commit f6074ee

Browse files
zrgts-heppner
authored andcommitted
Soften the language tag constraint
remove constraint, that if the second part of lang tag exists, it must be a region See #157
1 parent 03c1579 commit f6074ee

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

basyx/aas/model/base.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,10 @@ def __init__(self, dict_: Dict[str, str]):
288288
@classmethod
289289
def _check_language_tag_constraints(cls, ltag: str):
290290
split = ltag.split("-", 1)
291-
if len(split[0]) != 2 or not split[0].isalpha() or not split[0].islower():
292-
raise ValueError(f"The language code '{split[0]}' of the language tag '{ltag}' doesn't consist of exactly "
293-
"two lower-case letters!")
294-
if len(split) > 1 and (len(split[1]) != 2 or not split[1].isalpha() or not split[1].isupper()):
295-
raise ValueError(f"The extension '{split[1]}' of the language tag '{ltag}' doesn't consist of exactly "
296-
"two upper-case letters!")
291+
lang_code = split[0]
292+
if len(lang_code) != 2 or not lang_code.isalpha() or not lang_code.islower():
293+
raise ValueError(f"The language code of the language tag must consist of exactly two lower-case letters! "
294+
f"Given language tag and language code: '{ltag}', '{lang_code}'")
297295

298296
def __getitem__(self, item: str) -> str:
299297
return self._dict[item]

0 commit comments

Comments
 (0)