NotebookParser
- class NotebookParser(original_notebook_paths: list[str] | None = None)[source]
Main parsing class for notebooks.
NotebookParserutilizes that instance and class attributes are separated and class attributes allow sharing of information across instances. This is used to realize the mapping of checked parsed notebooks back to their original files.Initialize NotebookParser.
Initializing an instance of the class will save
original_notebook_paths, which is a List of paths to notebooks, to the class attributes, which can be accessed by all instances or all modules that know about the class. Iforiginal_notebook_pathsisn’t provided, the class attributes will stay as it was.- Parameters:
original_notebook_paths (List[str], optional) – List of paths to notebooks, by default None
Attributes Summary
input_line_mappingsList of input_line_mapping
intermediate_py_file_pathsList of paths to the parsed Notebooks
original_notebook_pathsList of paths to the original Notebooks
temp_pathPath of the temp folder the parsed notebooks were saved in
Methods Summary
Delete the created temporary directory if it exists and resets all class attributes.
Create intermediate files needed for analysis.
Return the mapping information needed to generate error messages.
Methods Documentation
- static clean_up() None[source]
Delete the created temporary directory if it exists and resets all class attributes.
- create_intermediate_py_file_paths() None[source]
Create intermediate files needed for analysis.
Parses all notebooks provided by
self.original_notebook_pathsand saves them to a temporary directory, iforiginal_notebook_paths, was provided at initialization.
- static get_mappings() Iterator[tuple[str, str, InputLineMapping]][source]
Return the mapping information needed to generate error messages.
The message corresponds to the original notebook and not the actually checked parsed one.
- Returns:
(
original_notebook_paths,intermediate_py_file_paths,input_line_mappings)original_notebook_pathsis the relative path of the tested notebook.intermediate_py_file_pathsis the absolute path of the checked notebook. Andinput_line_mappingis a dict of information about which input in the original notebook, is in what line in the corresponding pared notebook.- Return type:
Iterator[tuple[str, str, InputLineMapping]]
See also
input_line_mapping,create_intermediate_py_file