def test_match_link_to_mention_text_different_folder_as_note(
            self, processing_options, conversion_settings):
        mention = MentionNote(processing_options, 'my-mention-note', 'ws-1234',
                              'note-5678')

        # Mention note is the note this link links to
        mention_note = NimbusNote(processing_options,
                                  contents=[],
                                  conversion_settings=conversion_settings)
        mention_note.title = 'my-mention-note'

        mention_note_paths = NotePaths()
        # mention_note_paths.path_to_source_workspace = Path('source/workspace')
        # mention_note_paths.path_to_target_folder = Path('target')
        mention_note_paths.path_to_source_folder = Path('source')
        mention_note_paths.path_to_note_target = Path(
            'target/workspace/mention_note_folder')

        mention_note.note_paths = mention_note_paths

        dict_of_notes = {'my-mention-note': [mention_note]}

        # this is the note the mention link is in
        this_note_note_paths = NotePaths()
        this_note_note_paths.path_to_source_folder = Path('source')
        this_note_note_paths.path_to_target_folder = Path('target')
        this_note_note_paths.path_to_note_source = Path(
            'source/workspace/this_note_folder')
        this_note_note_paths.path_to_note_target = Path(
            'target/workspace/this_note_folder')

        nimbus_ids = NimbusIDs()

        mention.match_link_to_mention_text(nimbus_ids, dict_of_notes,
                                           this_note_note_paths)

        assert mention.target_path == {
            Path('../mention_note_folder/my-mention-note.md')
        }
        assert len(nimbus_ids.notes) == 1
        assert len(nimbus_ids.workspaces) == 1
コード例 #2
0
def initialise_new_note(zip_file, conversion_settings,
                        processing_options: NimbusProcessingOptions):
    new_note = NimbusNote(processing_options,
                          contents=[],
                          conversion_settings=conversion_settings)

    new_note.title = zip_file.stem.replace('_', ' ')

    new_note.note_paths.path_to_note_source = Path(zip_file.parent)

    new_note.note_paths.path_to_source_folder = conversion_settings.source_absolute_root

    dirty_workspace_folder_name = Path(zip_file.parent).relative_to(
        conversion_settings.source_absolute_root).parts[0]

    new_note.note_paths.path_to_source_workspace = Path(
        conversion_settings.source_absolute_root, dirty_workspace_folder_name)

    new_note.note_paths.path_to_target_folder = conversion_settings.export_folder_absolute
    new_note.note_paths.note_target_suffix = get_file_suffix_for(
        conversion_settings.export_format)

    new_note.note_paths.note_source_file_name = zip_file.name
    clean_file_name = helper_functions.generate_clean_filename(
        new_note.title, processing_options.filename_options)

    new_note.note_paths.note_target_file_name = Path(
        f'{clean_file_name}'
        f'{new_note.note_paths.note_target_suffix}')

    new_note.note_paths.set_note_target_path(processing_options)

    new_note.note_paths.set_path_to_attachment_folder(
        conversion_settings.attachment_folder_name, processing_options)

    return new_note