Skip to content

Commit

Permalink
New kwarg skip_nbpkg to load_notebook_nobackup
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Feb 25, 2025
1 parent f8724fc commit 249603e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/notebook/saving and loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ function _read_notebook_appeared_order!(cell_order::Vector{UUID}, collected_cell
end

"Load a notebook without saving it or creating a backup; returns a `Notebook`. REMEMBER TO CHANGE THE NOTEBOOK PATH after loading it to prevent it from autosaving and overwriting the original file."
function load_notebook_nobackup(@nospecialize(io::IO), @nospecialize(path::AbstractString))::Notebook
function load_notebook_nobackup(@nospecialize(io::IO), @nospecialize(path::AbstractString); skip_nbpkg::Bool=false)::Notebook
notebook_metadata = _read_notebook_metadata!(io)
collected_cells = _read_notebook_collected_cells!(io)
cell_order = _read_notebook_cell_order!(io, collected_cells)
nbpkg_ctx = _read_notebook_nbpkg_ctx(cell_order, collected_cells)
nbpkg_ctx = skip_nbpkg ? nothing : _read_notebook_nbpkg_ctx(cell_order, collected_cells)
appeared_order = _read_notebook_appeared_order!(cell_order, collected_cells)

appeared_cells_dict = filter(collected_cells) do (k, v)
Expand All @@ -340,9 +340,9 @@ end

# UTILS

function load_notebook_nobackup(path::String)::Notebook
function load_notebook_nobackup(path::String; kwargs...)::Notebook
open(path, "r") do io
load_notebook_nobackup(io, path)
load_notebook_nobackup(io, path; kwargs...)
end
end

Expand Down

0 comments on commit 249603e

Please sign in to comment.