##// END OF EJS Templates
fix base64 code in nbformat.v2...
fix base64 code in nbformat.v2 base64 encoding functions were called, but had no effect, because the notebook already has everything as b64-encoded bytestrings, which are valid ascii literals on Python 2. However, the encode/decode logic is actually triggered on Python 3, revealing its errors. This fixes the base64 functions that had no effect to have their intended effect, but does not use them. Rather, it is assumed that bytes objects are already b64-encoded (and thus ascii-safe), which assumption was already made in Python 2.

File last commit:

r4872:34c10438
r5175:155b20cc
Show More
display.py
35 lines | 833 B | text/x-python | PythonLexer
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 """Various display related classes.
Authors : MinRK
"""
class YouTubeVideo(object):
"""Class for embedding a YouTube Video in an IPython session, based on its video id.
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 e.g. to embed the video on this page:
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 http://www.youtube.com/watch?v=foo
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 you would do:
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 vid = YouTubeVideo("foo")
display(vid)
"""
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 def __init__(self, id, width=400, height=300):
self.id = id
self.width = width
self.height = height
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 def _repr_html_(self):
"""return YouTube embed iframe for this video id"""
return """
Bernardo B. Marques
remove all trailling spaces
r4872 <iframe
width="%i"
height="%i"
src="http://www.youtube.com/embed/%s"
frameborder="0"
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 allowfullscreen
></iframe>
"""%(self.width, self.height, self.id)