Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions keepnote/extensions/command_basics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ def __init__(self, app):
metavar="[v VERSION] NOTEBOOK...",
help="upgrade a notebook"),

# export commands
AppCommand("backup", self.on_backup,
metavar="NOTEBOOK BACKUP_FILE",
help="backup the notebook"),
AppCommand("export-html", self.on_export,
metavar="NOTEBOOK EXPORT_DIRECTORY",
help="export the notebook to html"),

# misc
AppCommand("screenshot", self.on_screenshot,
help="insert a new screenshot"),
Expand Down Expand Up @@ -327,3 +335,31 @@ def on_upgrade_notebook(self, app, args):
(version, filename))
keepnote.notebook.update.update_notebook(filename, version,
verify=True)


def on_backup(self,app,args):

try:
infile,outfile = args[1],args[2]
except IndexError:
sys.etderr.write("backup notebook failed"
"please provide two arguments to backup: "
"notebook location and output file")
return
notebook = app.get_notebook(infile)
bck = app.get_extension('backup_tar')
bck.archive_notebook(notebook,outfile)


def on_export(self,app,args):

try:
infile,outfile = args[1],args[2]
except IndexError:
sys.stderr.write("export notebook failed"
"please provide two arguments to export-html: "
"notebook location and output file")
return
notebook = app.get_notebook(infile)
ex = app.get_extension('export_html')
ex.export_notebook(notebook,outfile)