Esempio n. 1
0
 def test_description(self):
     file_id = 'BETTY01'
     file_path = '/tmp/betty'
     sut = File(file_id, file_path)
     description = 'Hi, my name is Betty!'
     sut.description = description
     self.assertEquals(description, sut.description)
Esempio n. 2
0
def _load_object(loader: _Loader, element: ElementTree.Element, gramps_tree_directory_path):
    handle = element.get('handle')
    entity_id = element.get('id')
    file_element = _xpath1(element, './ns:file')
    file_path = path.join(gramps_tree_directory_path, file_element.get('src'))
    file = File(entity_id, file_path)
    file.media_type = MediaType(file_element.get('mime'))
    description = file_element.get('description')
    if description:
        file.description = description
    note_handle_elements = _xpath(element, './ns:noteref')
    for note_handle_element in note_handle_elements:
        file.notes.append(loader._notes[note_handle_element.get('hlink')])
    _load_attribute_privacy(file, element, 'attribute')
    loader._files[handle] = _IntermediateFile(file, _load_citationref_as_handles(element))
Esempio n. 3
0
    async def test_file(self, expected: str, locale: str):
        file_id = 'F1'
        file = File(file_id, __file__)
        file.description = '"file" is Dutch for "traffic jam"'

        with TemporaryDirectory() as output_directory_path:
            configuration = Configuration(
                output_directory_path, 'https://example.com')
            configuration.locales['en-US'] = LocaleConfiguration('en-US', 'en')
            configuration.locales['nl-NL'] = LocaleConfiguration('nl-NL', 'nl')
            async with App(configuration).with_locale(locale) as app:
                app.ancestry.files[file_id] = file
                indexed = [item for item in Index(app).build()]

        self.assertEquals('"file" is dutch for "traffic jam"', indexed[0]['text'])
        self.assertIn(expected, indexed[0]['result'])
Esempio n. 4
0
def _parse_object(ancestry: _IntermediateAncestry, element: Element,
                  gramps_file_path):
    handle = _xpath1(element, './@handle')
    entity_id = str(_xpath1(element, './@id'))
    file_element = _xpath1(element, './ns:file')
    file_path = join(dirname(gramps_file_path),
                     str(_xpath1(file_element, './@src')))
    file = File(entity_id, file_path)
    file.type = str(_xpath1(file_element, './@mime'))
    description = str(_xpath1(file_element, './@description'))
    if description:
        file.description = description
    note_handles = _xpath(element, './ns:noteref/@hlink')
    for note_handle in note_handles:
        file.notes.append(ancestry.notes[note_handle])
    ancestry.files[handle] = file
Esempio n. 5
0
def _parse_object(ancestry: _IntermediateAncestry, element: Element,
                  gramps_directory_path):
    handle = _xpath1(element, './@handle')
    entity_id = str(_xpath1(element, './@id'))
    file_element = _xpath1(element, './ns:file')
    file_path = path.join(gramps_directory_path,
                          str(_xpath1(file_element, './@src')))
    file = File(entity_id, file_path)
    file.media_type = MediaType(str(_xpath1(file_element, './@mime')))
    description = str(_xpath1(file_element, './@description'))
    if description:
        file.description = description
    note_handles = _xpath(element, './ns:noteref/@hlink')
    for note_handle in note_handles:
        file.notes.append(ancestry.notes[note_handle])
    _parse_attribute_privacy(file, element, 'attribute')
    ancestry.files[handle] = file
Esempio n. 6
0
    def test_file(self, expected: str, locale: str):
        with TemporaryDirectory() as output_directory_path:
            configuration = Configuration(output_directory_path,
                                          'https://example.com')
            configuration.locales['en-US'] = LocaleConfiguration('en-US', 'en')
            configuration.locales['nl-NL'] = LocaleConfiguration('nl-NL', 'nl')
            site = Site(configuration)
            environment = create_environment(site, locale)
            file_id = 'F1'
            file = File(file_id, __file__)
            file.description = '"file" is Dutch for "traffic jam"'
            site.ancestry.files[file_id] = file

            indexed = list(index(site, environment))

            self.assertEquals('"file" is dutch for "traffic jam"',
                              indexed[0]['text'])
            self.assertIn(expected, indexed[0]['result'])