Example #1
0
def parse_event_date(event_element):
    date = get_value(event_element, tags.GEDCOM_TAG_DATE)
    # TODO: Support other date formats. Some require alternate date storage formats, like a custom string, or a range,
    #  or just a year.
    try:
        return datetime.datetime.strptime(date, "%d %b %Y").date()
    except ValueError:
        return None
Example #2
0
def parse_individual(element: IndividualElement, tree):
    child = Person()

    # get names from element
    names = list(get_names(element))

    # save legal name
    # assumes first name in list is primary name
    legal_name = LegalName()
    parse_name_dict(names[0], legal_name)
    legal_name.tree = tree
    legal_name.save()
    child.legal_name = legal_name

    # save alternate names
    for name_dict in names[1:]:
        alternate_name = AlternateName()
        parse_name_dict(name_dict, alternate_name)
        alternate_name.person = child
        alternate_name.tree = tree
        alternate_name.save()

    child.gender = parse_gender(get_value(element, tags.GEDCOM_TAG_SEX))

    # Is saving related models necessary, or will it cascade?
    birth_event_element = get_next_child_element(element,
                                                 tags.GEDCOM_TAG_BIRTH)
    if birth_event_element:
        child.birth_date = parse_event_date(birth_event_element)
        child.birth_location = parse_event_location(birth_event_element)

    death_event_element = get_next_child_element(element,
                                                 tags.GEDCOM_TAG_DEATH)
    if death_event_element:
        child.death_date = parse_event_date(death_event_element)
        child.death_location = parse_event_location(death_event_element)
        child.living = 'Dead'

    # living defaults to Unknown; change to living = has birth year and not has death year?

    child.tree = tree

    child.save()

    return element.get_pointer(), child
Example #3
0
def parse_event_location(event_element):
    place = get_value(event_element, tags.GEDCOM_TAG_PLACE)
    parts = place.split(' ')

    city, state, country = '', '', ''

    len_parts = len(parts)
    if len_parts >= 1:
        city = parts[0].strip(',')
    if len_parts >= 2:
        state = parts[1].strip(',')
    if len_parts >= 3:
        country = parse_country(parts[2])

    location, created = Location.objects.get_or_create(city=city,
                                                       state=state,
                                                       country=country)

    return location
Example #4
0
 def get_place(self):
     return helpers.get_value(self, tags.GEDCOM_TAG_PLACE)
Example #5
0
 def get_date(self):
     return helpers.get_value(self, tags.GEDCOM_TAG_DATE)
Example #6
0
 def get_submitter_ptr(self):
     return helpers.get_value(self, tags.GEDCOM_TAG_SUBMITTER)
Example #7
0
 def get_charset(self):
     """
     Returns the charset of a file
     """
     return helpers.get_value(self, tags.GEDCOM_TAG_CHARSET)
Example #8
0
 def get_form(self):
     return helpers.get_value(self, tags.GEDCOM_TAG_FORM)
Example #9
0
 def get_version(self):
     return helpers.get_value(self, tags.GEDCOM_TAG_VERSION)