markdown.obsidian.personal.note_type

Functions for distinguishing types of Obsidian.md notes that I use.
from fastcore.test import *

from trouver.helper import _test_directory

It should be convenient to be able to distinguish between different types of notes; thus far, I have made the following types of notes:

  1. index notes, which list other notes, usually standard information notes and usually in the order that they are found in texts/papers.
  2. “standard” information notes, which display a block of content or blocks or related content.
  3. “module” information notes, which contain a block of information to be embedded into other notes for common use.
  4. index of notation notes, which list notation used in a reference.
  5. notation notes, which describe what a single notation or few notations denote.
  6. premise notes, which relay commonly used notations/assumptions and which are embedded into
  7. common terms notes, which list out terms that have similar names that may or may not be related.
  8. templates, which are templates for standard information notes and index of notation notes.
  9. tags, which list out tags of similar concepts
  10. notes, which are notes of videos/lectures
  11. mathematician notes, which serve as a hub for basic information about individual mathematicians
  12. equation notes, which are used to embed and reference equations or, more generally, mathematical expressions.
  13. reference notes, which are usually embedded in “standard” information notes and list basic details about references/texts, including authors and where the reference is available online.
  14. terms notes, which list which notes serve as links to which terms in a reference.

PersonalNoteTypeEnum class


source

PersonalNoteTypeEnum

 PersonalNoteTypeEnum (value, names=None, module=None, qualname=None,
                       type=None, start=1)

An Enum class for note types in my Obsidian math vault

PersonalNoteTypeEnum.type_function(PersonalNoteTypeEnum.INDEX_NOTE)
<function __main__._is_index_note(vault_note: trouver.markdown.obsidian.vault.VaultNote) -> bool>
for note_type in PersonalNoteTypeEnum:
    print(note_type)
PersonalNoteTypeEnum.INDEX_NOTE
PersonalNoteTypeEnum.STANDARD_INFORMATION_NOTE
PersonalNoteTypeEnum.MODULE_INFORMATION_NOTE
PersonalNoteTypeEnum.INDEX_OF_NOTATION_NOTE
PersonalNoteTypeEnum.NOTATION_NOTE
PersonalNoteTypeEnum.PREMISE_NOTE
PersonalNoteTypeEnum.COMMON_TERMS_NOTE
PersonalNoteTypeEnum.TEMPLATE_NOTE
PersonalNoteTypeEnum.TAG_NOTE
PersonalNoteTypeEnum.NOTES_NOTE
PersonalNoteTypeEnum.MATHEMATICIAN_NOTE
PersonalNoteTypeEnum.EQUATION_NOTE
PersonalNoteTypeEnum.REFERENCE_NOTE
PersonalNoteTypeEnum.GLOSSARY_NOTE

source

type_of_note

 type_of_note (vault_note:trouver.markdown.obsidian.vault.VaultNote)

Returns the type of the specified note.

Assumes that vault_note represents an existing note.

Notes - This function may return incorrect or unintended results, depending on the formatting or existence of the file.

Raises - NoteDoesNoteExistError - If vault_note does not exist.


source

note_is_of_type

 note_is_of_type (vault_note:trouver.markdown.obsidian.vault.VaultNote,
                  note_type:Optional[__main__.PersonalNoteTypeEnum])

Returns True if the Markdown vault note exists and is determined to be of the specified type.

Assumes that vault_note represents an existing note.

Notes - This function may return incorrect results, depending on the formatting of the file.

Raises - NoteDoesNoteExistError - If vault_note does not exist.

Type Details
vault_note VaultNote
note_type typing.Optional[main.PersonalNoteTypeEnum] The type of note. If None, then any type of note; in this case, returns whether or not the note exists.
Returns bool

We can get the type of a note with type_of_note or tell whether a note is of a given type with note_is_of_type:

vault = _test_directory() / 'test_vault_4'

sample_vn_1 = VaultNote(vault, name='number_theory_reference_1_Definition 1.7')
assert type_of_note(sample_vn_1) == PersonalNoteTypeEnum.STANDARD_INFORMATION_NOTE
assert note_is_of_type(sample_vn_1, PersonalNoteTypeEnum.STANDARD_INFORMATION_NOTE)

sample_vn_2 = VaultNote(vault, name='_index_1_chapter_number_theory_reference_1')
assert type_of_note(sample_vn_2) == PersonalNoteTypeEnum.INDEX_NOTE

sample_vn_3 = VaultNote(vault, name='_notation_number_theory_reference_1')
assert type_of_note(sample_vn_3) == PersonalNoteTypeEnum.INDEX_OF_NOTATION_NOTE

sample_vn_4 = VaultNote(vault, name='number_theory_reference_1_notation_Z_nZ_ring_of_integers_modulo_n')
assert type_of_note(sample_vn_4) == PersonalNoteTypeEnum.NOTATION_NOTE

sample_vn_5 = VaultNote(vault, name='_glossary_number_theory_reference_1')
assert type_of_note(sample_vn_5) == PersonalNoteTypeEnum.GLOSSARY_NOTE

sample_vn_6 = VaultNote(vault, name='_common_terms_ring')
assert type_of_note(sample_vn_6) == PersonalNoteTypeEnum.COMMON_TERMS_NOTE

sample_vn_7 = VaultNote(vault, name='_template_number_theory_reference_1')
assert type_of_note(sample_vn_7) == PersonalNoteTypeEnum.TEMPLATE_NOTE

sample_vn_8 = VaultNote(vault, name='kim_hyun_jong')
assert type_of_note(sample_vn_8) == PersonalNoteTypeEnum.MATHEMATICIAN_NOTE

sample_vn_9 = VaultNote(vault, name='_reference_number_theory_reference_1')
assert type_of_note(sample_vn_9) == PersonalNoteTypeEnum.REFERENCE_NOTE
C:\Users\hyunj\AppData\Local\Temp\ipykernel_2268\3185867786.py:21: DeprecationWarning: Call to deprecated function (or staticmethod) _is_module_information_note.
  if type_function(vault_note):
C:\Users\hyunj\AppData\Local\Temp\ipykernel_2268\3185867786.py:21: DeprecationWarning: Call to deprecated function (or staticmethod) _is_tag_note.
  if type_function(vault_note):

If the note does not exist, then a NoteDoesNotExistError is raised:

non_existent_vn = VaultNote(vault, name='non_existent_note')
with ExceptionExpected(ex=NoteDoesNotExistError):
    type_of_note(non_existent_vn)

NoteTypeError


source

assert_note_is_of_type

 assert_note_is_of_type (note:trouver.markdown.obsidian.vault.VaultNote,
                         expected_type:__main__.PersonalNoteTypeEnum)

Raises a NoteTypeError if the note is not of the expected type.

Raises - NoteTypeError - If the type of note is not expected_type.


source

NoteTypeError

 NoteTypeError (note:trouver.markdown.obsidian.vault.VaultNote,
                expected_note_type:__main__.PersonalNoteTypeEnum)

Exception raised when the type of note is not of the expected type.

Attributes - note - VaultNote - expected_note_type - PersonalNoteTypeEnum

We can raise NoteTypeError when a note of some type is expected, but a note of a different type is passed:

vault = _test_directory() / 'test_vault_4'

not_a_notation_note = VaultNote(vault, name='number_theory_reference_1_Definition 1.7')
with ExceptionExpected(ex=NoteTypeError, regex="PersonalNoteTypeEnum.NOTATION_NOTE"):
    exception = NoteTypeError(not_a_notation_note, PersonalNoteTypeEnum.NOTATION_NOTE)
    print(exception)
    raise exception
Expected a note of type PersonalNoteTypeEnum.NOTATION_NOTE, but got a note of a different type instead: number_theory_reference_1_Definition 1.7

For convenience, the assert_note_is_of_type method checks that a note is of a specified type:

assert_note_is_of_type(not_a_notation_note, PersonalNoteTypeEnum.STANDARD_INFORMATION_NOTE)
with ExceptionExpected(ex=NoteTypeError, regex="PersonalNoteTypeEnum.NOTATION_NOTE"):
    assert_note_is_of_type(not_a_notation_note, PersonalNoteTypeEnum.NOTATION_NOTE)