Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102720277
slides
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 23, 12:23
Size
3 KB
Mime Type
text/x-python
Expires
Tue, Feb 25, 12:23 (1 d, 14 h)
Engine
blob
Format
Raw Data
Handle
24404810
Attached To
R3683 Slides
slides
View Options
#!/usr/bin/python3
from __future__ import print_function
"""
This executable permits to generate an advanced presentation
from a Jupyter notebook.
The capabilities are:
- a server of reveal content
- a pptx (under developement)
- a beamer tex file (TODO)
"""
################################################################
import argparse
import os
import Slides.count_slides as count_slides
import Slides.cell_manager as cell_manager
################################################################
def getNotebookFilenames(slides_path):
"""
When a directory is provided to the executable,
a file named 'slides' is searched for with
the expected list of ipython notebooks.
The list of notebooks to consider is then
returned.
"""
slides_file = os.path.join(slides_path, 'slides')
if not os.path.isfile(slides_file):
raise Exception("Cannot find slides file")
f = open(slides_file)
slides = [l.strip() for l in f.readlines()]
slides = [l for l in slides if not l == ""]
return slides
################################################################
def main():
parser = argparse.ArgumentParser(description='Slide launcher')
parser.add_argument(
"--execute", action='store_true',
help=('Requests to execute all the notebooks launching '
'the slides server'))
parser.add_argument("--no_count", action='store_false',
help="Requests not to count slides generated")
parser.add_argument("notebooks", nargs='*',
help="The notebooks to associate in a presentation")
parser.add_argument(
"--internet", action='store_true',
help="Weather the http server should serve on the internet")
parser.add_argument("--html", action='store_true',
help="only produce a html file")
parser.add_argument("--beamer", action='store_true',
help="produce a beamer/latex file and the pdf")
parser.add_argument("--add_cell_number", action='store_true',
help="add the cell number before each cell")
parser.add_argument("--select_cells", type=int, nargs='*',
help="Provides a list of cells to select")
parser.add_argument("--font_size", type=str, default='25px',
help="Provides the font size of the presentation")
arguments = parser.parse_args()
if len(arguments.notebooks) == 1:
if os.path.isdir(arguments.notebooks[0]):
arguments.notebooks = getNotebookFilenames(arguments.notebooks[0])
if arguments.execute:
for n in arguments.notebooks:
cell_manager.executeNotebook(n)
try:
cell_manager.mergeNotebooks(arguments.notebooks,
add_cell_number=arguments.add_cell_number,
select_cells=arguments.select_cells)
except cell_manager.NotFoundNotebooks:
print('Could not find the notebooks to treat: check path provided')
return
if arguments.no_count:
nb_slides = count_slides.countSlides(['talk.ipynb'])
print("*" * 20)
print("You generated a talk with {0} slides".format(nb_slides))
print("*" * 20)
if arguments.html:
cell_manager.generateHTML(font_size=arguments.font_size)
elif arguments.beamer:
cell_manager.generateBeamer(font_size=arguments.font_size)
elif arguments.internet:
cell_manager.launchSlideServer(options="--ServePostProcessor.ip='*'",
font_size=arguments.font_size)
else:
cell_manager.launchSlideServer(font_size=arguments.font_size)
################################################################
if __name__ == "__main__":
main()
Event Timeline
Log In to Comment