|
55 | 55 | )
|
56 | 56 |
|
57 | 57 | # from gramps.gen.lib.serialize import to_json
|
58 |
| -from gramps.gen.lib.json_utils import object_to_string, remove_object |
| 58 | +from gramps.gen.lib.json_utils import object_to_dict, object_to_string, remove_object |
59 | 59 | from gramps.gen.lib.primaryobj import BasicPrimaryObject as GrampsObject
|
60 | 60 | from gramps.gen.plug import BasePluginManager
|
61 | 61 | from gramps.gen.relationship import get_relationship_calculator
|
@@ -950,36 +950,36 @@ def fix_object_dict(object_dict: dict, class_name: Optional[str] = None):
|
950 | 950 | ):
|
951 | 951 | if isinstance(v, str):
|
952 | 952 | if class_name == "Family":
|
953 |
| - d_out[k] = { |
954 |
| - "_class": f"{class_name}RelType", |
955 |
| - "string": xml_to_locale(f"{class_name}RelType", v), |
956 |
| - } |
| 953 | + _class = "FamilyRelType" |
| 954 | + obj = gramps.gen.lib.__dict__[_class]() |
| 955 | + obj.set_from_xml_str(v) |
| 956 | + d_out[k] = object_to_dict(obj) |
957 | 957 | elif class_name == "RepoRef":
|
958 |
| - d_out[k] = { |
959 |
| - "_class": "SourceMediaType", |
960 |
| - "string": xml_to_locale("SourceMediaType", v), |
961 |
| - } |
| 958 | + _class = "SourceMediaType" |
| 959 | + obj = gramps.gen.lib.__dict__[_class]() |
| 960 | + obj.set_from_xml_str(v) |
| 961 | + d_out[k] = object_to_dict(obj) |
962 | 962 | else:
|
963 |
| - d_out[k] = { |
964 |
| - "_class": f"{class_name}Type", |
965 |
| - "string": xml_to_locale(f"{class_name}Type", v), |
966 |
| - } |
| 963 | + _class = f"{class_name}Type" |
| 964 | + obj = gramps.gen.lib.__dict__[_class]() |
| 965 | + obj.set_from_xml_str(v) |
| 966 | + d_out[k] = object_to_dict(obj) |
967 | 967 | else:
|
968 | 968 | d_out[k] = v
|
969 | 969 | elif k == "role":
|
970 | 970 | if isinstance(v, str):
|
971 |
| - d_out[k] = { |
972 |
| - "_class": "EventRoleType", |
973 |
| - "string": xml_to_locale("EventRoleType", v), |
974 |
| - } |
| 971 | + _class = "EventRoleType" |
| 972 | + obj = gramps.gen.lib.__dict__[_class]() |
| 973 | + obj.set_from_xml_str(v) |
| 974 | + d_out[k] = object_to_dict(obj) |
975 | 975 | else:
|
976 | 976 | d_out[k] = v
|
977 | 977 | elif k == "origintype":
|
978 | 978 | if isinstance(v, str):
|
979 |
| - d_out[k] = { |
980 |
| - "_class": "NameOriginType", |
981 |
| - "string": xml_to_locale("NameOriginType", v), |
982 |
| - } |
| 979 | + _class = "NameOriginType" |
| 980 | + obj = gramps.gen.lib.__dict__[_class]() |
| 981 | + obj.set_from_xml_str(v) |
| 982 | + d_out[k] = object_to_dict(obj) |
983 | 983 | else:
|
984 | 984 | d_out[k] = v
|
985 | 985 | elif k in ["rect", "mother_handle", "father_handle", "famc"] and not v:
|
|
0 commit comments