From 3ee908f1441a90be7c9102f56e175bc37dcc2f10 Mon Sep 17 00:00:00 2001 From: mqrause Date: Thu, 31 Oct 2024 14:15:46 +0100 Subject: [PATCH] fix profession parser --- lang/string_extractor/parsers/profession.py | 32 ++++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lang/string_extractor/parsers/profession.py b/lang/string_extractor/parsers/profession.py index ddbda3180b6cc..5367a34ac019e 100644 --- a/lang/string_extractor/parsers/profession.py +++ b/lang/string_extractor/parsers/profession.py @@ -14,23 +14,27 @@ def parse_profession(json, origin): desc_male = "" desc_female = "" - if type(json["description"]) is dict: - if "male" in json["description"]: - desc_male = json["description"]["male"] - desc_female = json["description"]["female"] - elif "str" in json["description"]: - desc_male = desc_female = json["description"]["str"] - else: - desc_male = desc_female = json["description"] + has_description = "description" in json + if has_description: + if type(json["description"]) is dict: + if "male" in json["description"]: + desc_male = json["description"]["male"] + desc_female = json["description"]["female"] + elif "str" in json["description"]: + desc_male = desc_female = json["description"]["str"] + else: + desc_male = desc_female = json["description"] write_text(name_male, origin, context="profession_male", comment="Profession name for male") - write_text(desc_male, origin, context="prof_desc_male", - comment="Description of profession \"{}\" for male". - format(name_male)) + if has_description: + write_text(desc_male, origin, context="prof_desc_male", + comment="Description of profession \"{}\" for male". + format(name_male)) write_text(name_female, origin, context="profession_female", comment="Profession name for female") - write_text(desc_female, origin, context="prof_desc_female", - comment="Description of profession \"{}\" for female". - format(name_female)) + if has_description: + write_text(desc_female, origin, context="prof_desc_female", + comment="Description of profession \"{}\" for female". + format(name_female))