Beispiel #1
0
def _load_event(loader: _Loader, element: ElementTree.Element):
    event_handle = element.get('handle')
    event_id = element.get('id')
    gramps_type = _xpath1(element, './ns:type')

    try:
        event_type = _EVENT_TYPE_MAP[gramps_type.text]
    except KeyError:
        event_type = UnknownEventType()
        getLogger().warning(
            'Betty is unfamiliar with Gramps event "%s"\'s type of "%s". The event was imported, but its type was set to "%s".'
            % (event_id, gramps_type.text, event_type.label))

    event = Event(event_id, event_type)

    event.date = _load_date(element)

    # Load the event place.
    place_handle = _load_handle('place', element)
    if place_handle is not None:
        loader.add_association(Event, event_handle, 'place', Place,
                               place_handle)

    # Load the description.
    description_element = _xpath1(element, './ns:description')
    if description_element is not None:
        event.description = description_element.text

    _load_attribute_privacy(event, element, 'attribute')

    flattened_event = FlattenedEntity(event, event_handle)
    _load_objref(loader, flattened_event, element)
    _load_citationref(loader, flattened_event, element)
    loader.add_entity(flattened_event)
 async def test_with_description(self):
     event = Event(None, Birth())
     event.description = 'Something happened!'
     expected = 'Birth (Something happened!)'
     async with self._render(data={
             'event': event,
     }) as (actual, _):
         self.assertEqual(expected, actual)