Skip to content

Commit

Permalink
Spanish edition: check "tags" more sensibly
Browse files Browse the repository at this point in the history
In case "tags" can be modified by sub-arguments.
  • Loading branch information
kristian-clausal committed Jan 10, 2024
1 parent e2b6a53 commit eb9b819
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/wiktextract/extractor/es/pronunciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,21 @@ def process_pron_graf_template(
spelling_data.append(spelling_v)

main_sound = variations[0]
for key in main_sound.model_fields_set | {"tags"}:
for key in main_sound.model_fields_set:
# because "tags" is a field that is never 'set' (just appended to)
# it apparently doesn't appear in mode_fields_set.
for i, other_variation in variations.items():
if i == 0:
continue
if key not in other_variation.model_fields_set:
setattr(other_variation, key, getattr(main_sound, key))
if main_sound.tags:
for i, other_variaton in variations.items():
if i == 0:
continue
if not other_variation.tags:
other_variations.tags = main_sound.tags.copy()

for sound in variations.values():
if len(sound.model_dump(exclude_defaults=True)) > 0:
sound_data.append(sound)
Expand Down

0 comments on commit eb9b819

Please sign in to comment.