glossary: now supports quoted and unquoted entries (incl. tests)

This commit is contained in:
2024-02-05 08:26:27 +01:00
parent a1a090bcae
commit 580c506483
2 changed files with 45 additions and 5 deletions
+5 -1
View File
@@ -58,7 +58,11 @@ class Glossary:
raise GlossaryError(f"File type '{file_path.suffix}' is not supported")
with open(file_path, "r") as fd:
try:
data = yaml.load(fd, Loader=yaml.FullLoader)
# use BaseLoader so every entry is read as a string
# - disables automatic conversions
# - makes it possible to omit quoting for YAML keywords in entries (e. g. 'yes')
# - also correctly reads quoted entries
data = yaml.load(fd, Loader=yaml.BaseLoader)
clean_entries = data['Entries']
return cls(name=data['Name'],
source_lang=data['SourceLang'],