losalamos.notes#
{Short module description (1-3 sentences)} todo docstring
Classes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- class losalamos.notes.Note(name='MyNote', alias='Nt1')[source]#
Bases:
MbaE- get_metadata()[source]#
This method returns all objects metadata, incluiding selected attributes beyond the metadata of the file
- save()[source]#
Save object resources to sourced files.
Danger
This method overwrites the sourced data file.
- export(folder, filename, export_metadata=False)[source]#
Export to a markdown file with optional metadata handling.
- Parameters:
folder (str) – The directory path where the file will be saved.
filename (str) – The name of the file without the extension.
export_metadata (bool) – Toggle to trigger the parent class metadata export. Default value =
False
- Returns:
Path to the exported file
- Return type:
Path
Note
This method constructs a file path using
pathlib.Pathand appends the.mdextension. It calls the internalto_filemethod withcleanupenabled to finalize the document. Ifexport_metadatais set toTrue, it invokes theexportmethod of the superclass before proceeding.
- to_file(file_path, cleanup=True)[source]#
Write the note object’s metadata and data content to a specified file.
- Parameters:
file_path (str) – The destination path where the note will be written.
cleanup (bool) – Toggle to remove excessive blank lines after writing. Default value =
True
- Returns:
None
- Return type:
NoneType
Note
This method aggregates metadata and data by calling
metadata_to_listanddata_to_list. It sanitizes the output by replacingNonestring occurrences with empty strings and ensures each entry ends with a newline character. Ifcleanupis enabled, it post-processes the file usingremove_excessive_blank_linesto maintain consistent formatting.
- static remove_excessive_blank_lines(file_path)[source]#
Remove consecutive blank lines from a file to ensure only single blank lines remain.
- Parameters:
file_path (str) – The path to the target text file to be processed.
- Returns:
None
- Return type:
NoneType
Note
This method performs an in-place modification of the file. It iterates through the content and suppresses any sequence of empty lines that exceeds a single occurrence, effectively “squeezing” the vertical whitespace.
- static parse_metadata(note_file)[source]#
Extracts YAML metadata from the header of a Markdown file.
- Parameters:
note_file – str, path to the Markdown file
- Returns:
dict, extracted YAML metadata
- static parse_yaml(yaml_content)[source]#
Parses YAML content into a dictionary.
- Parameters:
yaml_content – str, YAML content as string
- Returns:
dict, parsed YAML content
- static metadata_to_list(metadata_dict)[source]#
Convert a dictionary of metadata into a formatted list of strings.
- Parameters:
metadata_dict (dict) – A dictionary containing metadata keys and values to be formatted.
- Returns:
A list of strings formatted with YAML-like syntax, enclosed by dashed separators.
- Return type:
list
Note
The method processes dictionary entries into a human-readable list format. It handles list values by creating indented bullet points and converts
Nonevalues into empty strings. The resulting list starts and ends with a---delimiter string.
- static data_to_list(data_dict)[source]#
Flatten a dictionary of lists into a single list separated by blank lines and delimiters.
- Parameters:
data_dict (dict) – A dictionary where each key maps to a list of strings to be aggregated.
- Returns:
A concatenated list of all values with added structural spacing and separators.
- Return type:
list
Note
This function iterates through the top-level keys of
data_dictand appends the contents of each list to a master list. After each group of data, it inserts an empty string, a---separator, and another empty string to visually distinguish different levels or sections.
- static parse_note(file_path)[source]#
Extract and categorize note content into head, body, and tail sections based on separators.
- Parameters:
file_path (str) – The path to the note file to be parsed.
- Returns:
A dictionary containing the cleaned lines for
Head,Body, andTail.- Return type:
dict
Note
The function first identifies and skips an initial YAML frontmatter block if it starts with
---. It then uses the---string as a delimiter to segment the remaining text. If multiple separators exist, the first and last act as boundaries for theBody, while everything before the first isHeadand everything after the last isTail. All extracted lines undergo astrip()operation to remove leading/trailing whitespace.
- static list_by_pattern(md_dict, patt_type='tag')[source]#
Retrieve a list of patterns from the note dictionary.
- Parameters:
md_dict (dict) – Dictionary containing note sections.
patt_type (str) – Type of pattern to search for, either “tag” or “related”. Defaults to “tag”.
- Returns:
List of found patterns or None if no patterns are found.
- Return type:
list or None
- class losalamos.notes.NoteBasic(name='MyNote', alias='Nt1')[source]#
Bases:
Note- TEMPLATE_FILE = WindowsPath('C:/Users/Ipo/PycharmProjects/losalamos/src/losalamos/data/templates/notes/_basic.md')#
- THUMBNAIL_SIZE = None#
- classmethod get_template_file()[source]#
Retrieves the filesystem path of the template file associated with the class.
- Returns:
The path to the template file.
- Return type:
pathlib.Path
- load_new(file_note)[source]#
Initializes a new note instance using a template and assigns it a new file path.
- Parameters:
file_note (str or
pathlib.Path) – The destination path where the new note will be saved.
- load_data_standard()[source]#
Parses and returns the standard data content from the template file.
- Returns:
A dictionary containing the parsed data from the template.
- Return type:
dict
- load_metadata_standard()[source]#
Retrieves the metadata structure from the template and initializes all values to
None.- Returns:
A dictionary of metadata keys with cleared values.
- Return type:
dict
- load_metadata()[source]#
Loads metadata and synchronizes it against the standard template schema.
Important
This method filters the current metadata to ensure only keys present in
metadata_standardare kept, filling missing keys withNone.- Returns:
No value is returned.
- Return type:
None
- reset_data()[source]#
Resets all data segments including
Head,BodyandTailto their standard values.Danger
This action will erase all current data in the instance.
- reset_data_segment(segment)[source]#
Resets a specific data segment to its standard default state.
- Parameters:
segment (str) – The name of the data segment to reset (e.g.,
Head,Body, orTail).
Danger
This action will erase the current data for the specified segment.
- reset_data_head()[source]#
Resets the
Headdata segment to its standard default state.Danger
This action will erase the current data segment.
- reset_data_body()[source]#
Resets the
Bodydata segment to its standard default state.Danger
This action will erase the current data segment.
- reset_data_tail()[source]#
Resets the
Taildata segment to its standard default state.Danger
This action will erase the current data segment.
- update()[source]#
Triggers a sequence of internal updates to synchronize the note’s name, abstract, and thumbnail.
Note
This method acts as a base update sequence; additional update logic may be implemented in downstream classes.
- update_name()[source]#
Updates the note metadata and the first line of the Head segment with the current file stem.
Warning
This method assumes the first item in the
Headdata segment is the title and will overwrite it.
- update_abstract()[source]#
Synchronizes the abstract from metadata into the Head data segment block.
Note
The method searches for the
[!Abstract]identifier within theHeadsegment and replaces the subsequent line with the formatted abstract string.
- class losalamos.notes.NoteProject(name='MyNote', alias='Nt1')[source]#
Bases:
NoteBasic- TEMPLATE_FILE = WindowsPath('C:/Users/Ipo/PycharmProjects/losalamos/src/losalamos/data/templates/notes/_project.md')#
- THUMBNAIL_SIZE = None#
- class losalamos.notes.NoteJournal(name='MyNote', alias='Nt1')[source]#
Bases:
NoteBasic- TEMPLATE_FILE = WindowsPath('C:/Users/Ipo/PycharmProjects/losalamos/src/losalamos/data/templates/notes/_journal.md')#
- THUMBNAIL_SIZE = 300#
- class losalamos.notes.NoteFigure(name='MyNote', alias='Nt1')[source]#
Bases:
NoteBasic- TEMPLATE_FILE = WindowsPath('C:/Users/Ipo/PycharmProjects/losalamos/src/losalamos/data/templates/notes/_figure.md')#
- THUMBNAIL_SIZE = 500#
- class losalamos.notes.NoteCollection(name='MyNoteColl', alias='NtCol0')[source]#
Bases:
Collection- load_list(files)[source]#
Iterates through a list of file paths to initialize, load, and append objects to the collection.
- Parameters:
files (list) – A list of file paths to be processed.
- Returns:
None
- Return type:
None
- class losalamos.notes.NoteCollBasic(name='MyNoteColl', alias='NtCol0')[source]#
Bases:
NoteCollection
- class losalamos.notes.NoteCollProject(name='MyNoteColl', alias='NtCol0')[source]#
Bases:
NoteCollection- BASE_OBJECT#
alias of
NoteProject
- class losalamos.notes.NoteCollJournal(name='MyNoteColl', alias='NtCol0')[source]#
Bases:
NoteCollection- BASE_OBJECT#
alias of
NoteJournal
- class losalamos.notes.NoteCollFigure(name='MyNoteColl', alias='NtCol0')[source]#
Bases:
NoteCollection- BASE_OBJECT#
alias of
NoteFigure