Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101604552
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
Wed, Feb 12, 00:08
Size
3 KB
Mime Type
text/x-python
Expires
Fri, Feb 14, 00:08 (2 d)
Engine
blob
Format
Raw Data
Handle
24198998
Attached To
R3683 Slides
slides
View Options
#!/usr/bin/python3
"""
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_file):
"""
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.
"""
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() if _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]):
slides_path = arguments.notebooks[0]
slides_file = os.path.join(slides_path, 'slides')
arguments.notebooks = getNotebookFilenames(slides_file)
else:
_file = arguments.notebooks[0]
f, ext = os.path.splitext(_file)
if ext == '.sld':
arguments.notebooks = getNotebookFilenames(_file)
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