def get_person_profile_for_object(db_handle: DbReadBase, person: Person, args: List, locale: GrampsLocale = glocale) -> Person: """Get person profile given a Person.""" options = [] if "all" in args or "ratings" in args: options.append("ratings") name_display = NameDisplay(xlocale=locale) birth, birth_event = get_birth_profile(db_handle, person, args=options, locale=locale) death, death_event = get_death_profile(db_handle, person, args=options, locale=locale) if "all" in args or "age" in args: options.append("age") if birth_event is not None: birth["age"] = locale.translation.sgettext("0 days") if death_event is not None: death["age"] = (Span(birth_event.date, death_event.date).format( precision=3, dlocale=locale).strip("()")) profile = { "handle": person.handle, "gramps_id": person.gramps_id, "sex": get_sex_profile(person), "birth": birth, "death": death, "name_given": name_display.display_given(person), "name_surname": person.primary_name.get_surname(), } if "all" in args or "span" in args: options.append("span") if "all" in args or "events" in args: options.append("events") if "age" not in args and "all" not in args: birth_event = None profile["events"] = [ get_event_profile_for_handle( db_handle, event_ref.ref, args=options, base_event=birth_event, label="age", locale=locale, role=locale.translation.sgettext( event_ref.get_role().xml_str()), ) for event_ref in person.event_ref_list ] if "all" in args or "families" in args: primary_parent_family_handle = person.get_main_parents_family_handle() profile["primary_parent_family"] = get_family_profile_for_handle( db_handle, primary_parent_family_handle, options, locale=locale) profile["other_parent_families"] = [] for handle in person.parent_family_list: if handle != primary_parent_family_handle: profile["other_parent_families"].append( get_family_profile_for_handle(db_handle, handle, options, locale=locale)) profile["families"] = [ get_family_profile_for_handle(db_handle, handle, options, locale=locale) for handle in person.family_list ] return profile