from fastcore.test import *
from trouver.helper import _test_directory
markdown.obisidian.personal.notes
Functions for managing notes in an Obsidian.md math vault
Get notes linked in notes
notes_linked_in_notes_linked_in_note
notes_linked_in_notes_linked_in_note (list_note:trouver.markdown.obsidia n.vault.VaultNote, as_dict:bool=True)
Returns a list or dict of VaultNotes of notes linked by notes which are linked by a specified note.
Type | Default | Details | |
---|---|---|---|
list_note | VaultNote | The VaultNote with links to notes containing the links to obtain. |
|
as_dict | bool | True | If True , returns a dict. Returns a list otherwise. |
Returns | typing.Union[dict[str, trouver.markdown.obsidian.vault.VaultNote], list[trouver.markdown.obsidian.vault.VaultNote]] | If dict, the keys are the names of the vault notes and the values are the VaultNote objects. If list, then the entries are the VaultNote objects. |
notes_linked_in_note
notes_linked_in_note (list_note:trouver.markdown.obsidian.vault.VaultNot e, as_dict:bool=True)
Returns a list or dict of VaultNotes of notes linked by a specified note.
Type | Default | Details | |
---|---|---|---|
list_note | VaultNote | The VaultNote in which to find the links. |
|
as_dict | bool | True | If True , returns a dict. Returns a list otherwise. |
Returns | typing.Union[dict[str, trouver.markdown.obsidian.vault.VaultNote], list[trouver.markdown.obsidian.vault.VaultNote]] | If dict, the keys are the names of the vault notes and the values are the VaultNote objects. If list, then the entries are the VaultNote objects. |
# notes_linked_in_note(VaultNote(VAULT, name='ml_data_note_type_categorization'))
= _test_directory() / 'test_vault_3'
test_vault = VaultNote(test_vault, name='_index_1_chapter_reference_1')
index_note
= notes_linked_in_note(index_note)
notes_as_dict assert isinstance(notes_as_dict, dict)
len(notes_as_dict), 12)
test_eq(for name, note in notes_as_dict.items():
assert note.name == name
print(notes_as_dict)
= notes_linked_in_note(index_note)
notes_as_list len(notes_as_list), 12)
test_eq(print(notes_as_list)
# print(notes)
{'note_11': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_12': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_13': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_14': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_15': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_16': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_17': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_18': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_19': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_110': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_111': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_112': <trouver.markdown.obsidian.vault.VaultNote object>}
{'note_11': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_12': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_13': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_14': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_15': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_16': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_17': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_18': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_19': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_110': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_111': <trouver.markdown.obsidian.vault.VaultNote object>, 'note_112': <trouver.markdown.obsidian.vault.VaultNote object>}
= _test_directory() / 'test_vault_3'
test_vault = VaultNote(test_vault, name='_index_reference_1')
index_note
# This gets all the notes linked in the notes linked in `index_reference_1`.
# In other words, this gets all the notes linked in
# - `_index_1_chapter_reference_1`
# - `_index_2_chapter_reference_1`, and
# - `_index_3_chapter_reference_1`.
= notes_linked_in_notes_linked_in_note(index_note)
notes_as_dict assert isinstance(notes_as_dict, dict)
len(notes_as_dict), 17)
test_eq(for name, note in notes_as_dict.items():
assert note.name == name
assert 'note_without_a_section' in notes_as_dict
assert "note_titles don't really need much structure" in notes_as_dict
= notes_linked_in_notes_linked_in_note(index_note)
notes_as_list len(notes_as_list), 17) test_eq(