from fastcore.test import *
from trouver.helper.tests import _test_directorymarkdown.obsidian.personal.note_type
It should be convenient to be able to distinguish between different types of notes; thus far, I have made the following types of notes:
- index notes, which list other notes, usually standard information notes and usually in the order that they are found in texts/papers.
- “standard” information notes, which display a block of content or blocks or related content.
- “module” information notes, which contain a block of information to be embedded into other notes for common use.
- index of notation notes, which list notation used in a reference.
- notation notes, which describe what a single notation or few notations denote.
- premise notes, which relay commonly used notations/assumptions and which are embedded into
- common terms notes, which list out terms that have similar names that may or may not be related.
- templates, which are templates for standard information notes and index of notation notes.
- tags, which list out tags of similar concepts
- notes, which are notes of videos/lectures
- mathematician notes, which serve as a hub for basic information about individual mathematicians
- equation notes, which are used to embed and reference equations or, more generally, mathematical expressions.
- 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.
- terms notes, which list which notes serve as links to which terms in a reference.
PersonalNoteTypeEnum class
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.INDEX_OF_NOTATION_NOTE
PersonalNoteTypeEnum.NOTATION_NOTE
PersonalNoteTypeEnum.PREMISE_NOTE
PersonalNoteTypeEnum.COMMON_TERMS_NOTE
PersonalNoteTypeEnum.TEMPLATE_NOTE
PersonalNoteTypeEnum.NOTES_NOTE
PersonalNoteTypeEnum.MATHEMATICIAN_NOTE
PersonalNoteTypeEnum.EQUATION_NOTE
PersonalNoteTypeEnum.REFERENCE_NOTE
PersonalNoteTypeEnum.GLOSSARY_NOTE
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.*
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 | Optional | 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_NOTEIf 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
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.*
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 exceptionExpected 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)