Exemplo n.º 1
0
    def add_person(
        self,
        handle: Handle,
        anchor: bool = False,
        start: bool = True,
        end: bool = True,
        ancestors: int = 1,
        offspring: int = 1,
    ):
        """Add events for a person to the timeline."""
        if self.anchor_person and handle == self.anchor_person.handle:
            return
        person = self.db_handle.get_person_from_handle(handle)
        if person.handle not in self.birth_dates:
            event = get_birth_or_fallback(self.db_handle, person)
            if event:
                self.birth_dates.update({person.handle: event.date})
        for event_ref in person.event_ref_list:
            event = self.db_handle.get_event_from_handle(event_ref.ref)
            role = event_ref.get_role().xml_str()
            self.add_event((event, person, "self", role))
        if anchor and not self.anchor_person:
            self.anchor_person = person
            self.depth = max(ancestors, offspring) + 1
            if self.start_date is None and self.end_date is None:
                if len(self.timeline) > 0:
                    if start or end:
                        self.timeline.sort(key=lambda x: x[0].get_date_object(
                        ).get_sort_value())
                        if start:
                            self.start_date = self.timeline[0][0].date
                        if end:
                            if self.is_death_indicator(self.timeline[-1][0]):
                                self.end_date = self.timeline[-1][0].date
                            else:
                                data = probably_alive_range(
                                    person, self.db_handle)
                                self.end_date = data[1]

            for family in person.parent_family_list:
                self.add_family(family, ancestors=ancestors)

            for family in person.family_list:
                self.add_family(family,
                                anchor=person,
                                ancestors=ancestors,
                                offspring=offspring)
        else:
            for family in person.family_list:
                self.add_family(family, anchor=person, events_only=True)
Exemplo n.º 2
0
    def get(self, args: Dict, handle: Handle) -> Response:
        """Determine estimated birth and death dates."""
        db_handle = get_db_handle()
        locale = get_locale_for_language(args["locale"], default=True)
        person = get_person_by_handle(db_handle, handle)
        if person == {}:
            abort(404)

        data = probably_alive_range(
            person,
            db_handle,
            max_sib_age_diff=args["max_sibling_age_difference"],
            max_age_prob_alive=args["max_age_probably_alive"],
            avg_generation_gap=args["average_generation_gap"],
        )

        profile = {
            "birth": locale.date_displayer.display(data[0]),
            "death": locale.date_displayer.display(data[1]),
            "explain": data[2],
            "other": data[3],
        }
        return self.response(200, profile)
 def calc_estimates(self, person):
     return probably_alive_range(person, self.db,
                      self.MAX_SIB_AGE_DIFF,
                      self.MAX_AGE_PROB_ALIVE,
                      self.AVG_GENERATION_GAP)
 def calc_estimates(self, person):
     return probably_alive_range(person, self.db,
                      self.MAX_SIB_AGE_DIFF,
                      self.MAX_AGE_PROB_ALIVE,
                      self.AVG_GENERATION_GAP)