Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More review changes.

* Favicon.ico is served.
* Test suit now passes.
* Help links work for for me.
* Other changes made to address inline comments.
* The printing of long lines is an extremely subtle issue and I will open an issue for it.
* zmqws.py is completely gone so the naked print is not an issue.
* ipython-notebook removed from scripts.
* Updated copyright and authors of files.
* Fixed missing docstrings in IPython.nbformat.
  • Loading branch information...
commit a661b7c0002f3bc8a60592f87b0a0241f0b65320 1 parent 2c580e7
@ellisonbg ellisonbg authored
Showing with 442 additions and 71 deletions.
  1. +0 −8 IPython/__init__.py
  2. +1 −2  IPython/core/magic.py
  3. +5 −4 IPython/core/profileapp.py
  4. +13 −2 IPython/frontend/html/notebook/handlers.py
  5. +8 −3 IPython/frontend/html/notebook/kernelmanager.py
  6. +16 −10 IPython/frontend/html/notebook/notebookapp.py
  7. +11 −6 IPython/frontend/html/notebook/notebookmanager.py
  8. BIN  IPython/frontend/html/notebook/static/favicon.ico
  9. +6 −0 IPython/frontend/html/notebook/static/js/cell.js
  10. +6 −0 IPython/frontend/html/notebook/static/js/codecell.js
  11. +6 −0 IPython/frontend/html/notebook/static/js/kernel.js
  12. +6 −0 IPython/frontend/html/notebook/static/js/kernelstatus.js
  13. +6 −0 IPython/frontend/html/notebook/static/js/layout.js
  14. +6 −0 IPython/frontend/html/notebook/static/js/leftpanel.js
  15. +7 −0 IPython/frontend/html/notebook/static/js/namespace.js
  16. +6 −0 IPython/frontend/html/notebook/static/js/nbbrowser_main.js
  17. +6 −0 IPython/frontend/html/notebook/static/js/notebook.js
  18. +6 −0 IPython/frontend/html/notebook/static/js/notebook_main.js
  19. +7 −1 IPython/frontend/html/notebook/static/js/notebooklist.js
  20. +6 −0 IPython/frontend/html/notebook/static/js/pager.js
  21. +7 −1 IPython/frontend/html/notebook/static/js/panelsection.js
  22. +7 −1 IPython/frontend/html/notebook/static/js/savewidget.js
  23. +6 −0 IPython/frontend/html/notebook/static/js/textcell.js
  24. +6 −0 IPython/frontend/html/notebook/static/js/utils.js
  25. +0 −13 IPython/frontend/html/notebook/tests/test_kernelsession.py
  26. +22 −6 IPython/frontend/html/notebook/zmqhttp.py
  27. +21 −0 IPython/nbformat/current.py
  28. +12 −0 IPython/nbformat/v1/__init__.py
  29. +11 −0 IPython/nbformat/v1/convert.py
  30. +20 −1 IPython/nbformat/v1/nbbase.py
  31. +20 −1 IPython/nbformat/v1/nbjson.py
  32. +21 −0 IPython/nbformat/v1/rwbase.py
  33. +20 −0 IPython/nbformat/v2/__init__.py
  34. +31 −1 IPython/nbformat/v2/convert.py
  35. +25 −1 IPython/nbformat/v2/nbbase.py
  36. +20 −1 IPython/nbformat/v2/nbjson.py
  37. +20 −1 IPython/nbformat/v2/nbpy.py
  38. +21 −1 IPython/nbformat/v2/nbxml.py
  39. +24 −0 IPython/nbformat/v2/rwbase.py
  40. +0 −7 IPython/scripts/ipython-notebook
View
8 IPython/__init__.py
@@ -43,14 +43,6 @@
from .config.loader import Config
from .core import release
from .core.application import Application
-# Todo: Should these be imported here? We need to rethink what is imported in
-# this module.
-#from .core.display import (
-# display, display_pretty, display_html, display_latex,
-# display_png, display_jpeg, display_svg, display_json,
-# display_javascript, HTML, SVG, Math, Image, JSON,
-# Javascript, Pretty
-#)
from .frontend.terminal.embed import embed
from .core.error import TryNext
from .core.interactiveshell import InteractiveShell
View
3  IPython/core/magic.py
@@ -48,8 +48,7 @@
from IPython.core.fakemodule import FakeModule
from IPython.core.profiledir import ProfileDir
from IPython.core.macro import Macro
-from IPython.core import magic_arguments
-from IPython.core import page
+from IPython.core import magic_arguments, page
from IPython.core.prefilter import ESC_MAGIC
from IPython.lib.pylabtools import mpl_runner
from IPython.testing.skipdoctest import skip_doctest
View
9 IPython/core/profileapp.py
@@ -195,11 +195,12 @@ def init_config_files(self):
apps.append(IPythonQtConsoleApp)
try:
from IPython.frontend.html.notebook.notebookapp import IPythonNotebookApp
- except Exception:
- # this should be ImportError, but under weird circumstances
- # this might be an AttributeError, or possibly others
- # in any case, nothing should cause the profile creation to crash.
+ except ImportError:
pass
+ except Exception:
+ self.log.debug('Unexpected error when importing IPythonNotebookApp',
+ exc_info=True
+ )
else:
apps.append(IPythonNotebookApp)
if self.parallel:
View
15 IPython/frontend/html/notebook/handlers.py
@@ -1,9 +1,20 @@
-"""Tornado handlers for the notebook."""
+"""Tornado handlers for the notebook.
+
+Authors:
+
+* Brian Granger
+"""
#-----------------------------------------------------------------------------
-# Imports
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
from tornado import web
from tornado import websocket
View
11 IPython/frontend/html/notebook/kernelmanager.py
@@ -1,10 +1,15 @@
-"""A kernel manager for multiple kernels."""
+"""A kernel manager for multiple kernels.
+
+Authors:
+
+* Brian Granger
+"""
#-----------------------------------------------------------------------------
-# Copyright (C) 2011 The IPython Development Team
+# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
-# the file COPYING.txt, distributed as part of this software.
+# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
View
26 IPython/frontend/html/notebook/notebookapp.py
@@ -1,10 +1,15 @@
-"""A tornado based IPython notebook server."""
+"""A tornado based IPython notebook server.
+
+Authors:
+
+* Brian Granger
+"""
#-----------------------------------------------------------------------------
-# Copyright (C) 2011 The IPython Development Team
+# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
-# the file COPYING.txt, distributed as part of this software.
+# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
@@ -194,9 +199,9 @@ def parse_command_line(self, argv=None):
argv = sys.argv[1:]
self.kernel_argv = list(argv) # copy
- # kernel should inherit default config file from frontend
+ # Kernel should inherit default config file from frontend
self.kernel_argv.append("--KernelApp.parent_appname='%s'"%self.name)
- # scrub frontend-specific flags
+ # Scrub frontend-specific flags
for a in argv:
if a.startswith('-') and a.lstrip('-') in notebook_flags:
self.kernel_argv.remove(a)
@@ -205,7 +210,6 @@ def parse_command_line(self, argv=None):
alias = a.lstrip('-').split('=')[0]
if alias in notebook_aliases:
self.kernel_argv.remove(a)
- print self.kernel_argv
def init_configurables(self):
# Don't let Qt or ZMQ swallow KeyboardInterupts.
@@ -241,18 +245,20 @@ def initialize(self, argv=None):
self.log.critical('WARNING: the notebook server is listening on all IP addresses '
'but not using any encryption or authentication. This is highly '
'insecure and not recommended.')
- for i in range(10):
+
+ # Try random ports centered around the default.
+ from random import randint
+ n = 50 # Max number of attempts, keep reasonably large.
+ for port in [self.port] + [self.port + randint(-2*n, 2*n) for i in range(n)]:
try:
- port = self.port + i
self.http_server.listen(port, self.ip)
except socket.error, e:
if e.errno != errno.EADDRINUSE:
raise
- self.log.info('The port %i is already in use, trying: %i' % (port, port+1))
+ self.log.info('The port %i is already in use, trying another random port.' % port)
else:
self.port = port
break
-
def start(self):
ip = self.ip if self.ip else '[all ip addresses on your system]'
View
17 IPython/frontend/html/notebook/notebookmanager.py
@@ -1,8 +1,15 @@
+"""A notebook manager that uses the local file system for storage.
+
+Authors:
+
+* Brian Granger
+"""
+
#-----------------------------------------------------------------------------
-# Copyright (C) 2011 The IPython Development Team
+# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
-# the file COPYING.txt, distributed as part of this software.
+# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
@@ -46,7 +53,7 @@ def list_notebooks(self):
dict(notebook_id=notebook,name=name)
"""
names = os.listdir(self.notebook_dir)
- names = [name.split(u'.')[0] \
+ names = [name.split(u'.')[0]
for name in names if name.endswith(self.filename_ext)]
data = []
for name in names:
@@ -76,9 +83,7 @@ def notebook_exists(self, notebook_id):
if notebook_id not in self.mapping:
return False
path = self.get_path_by_name(self.mapping[notebook_id])
- if not os.path.isfile(path):
- return False
- return True
+ return os.path.isfile(path)
def find_path(self, notebook_id):
"""Return a full path to a notebook given its notebook_id."""
View
BIN  IPython/frontend/html/notebook/static/favicon.ico
Binary file not shown
View
6 IPython/frontend/html/notebook/static/js/cell.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Cell
View
6 IPython/frontend/html/notebook/static/js/codecell.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// CodeCell
View
6 IPython/frontend/html/notebook/static/js/kernel.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Kernel
View
6 IPython/frontend/html/notebook/static/js/kernelstatus.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Kernel Status widget
View
6 IPython/frontend/html/notebook/static/js/layout.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Layout
View
6 IPython/frontend/html/notebook/static/js/leftpanel.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// LeftPanel
View
7 IPython/frontend/html/notebook/static/js/namespace.js
@@ -1,3 +1,10 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
+
var IPython = IPython || {};
IPython.namespace = function (ns_string) {
View
6 IPython/frontend/html/notebook/static/js/nbbrowser_main.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// On document ready
View
6 IPython/frontend/html/notebook/static/js/notebook.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Notebook
View
6 IPython/frontend/html/notebook/static/js/notebook_main.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// On document ready
View
8 IPython/frontend/html/notebook/static/js/notebooklist.js
@@ -1,6 +1,12 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
-// Cell
+// NotebookList
//============================================================================
var IPython = (function (IPython) {
View
6 IPython/frontend/html/notebook/static/js/pager.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Pager
View
8 IPython/frontend/html/notebook/static/js/panelsection.js
@@ -1,6 +1,12 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
-// Cell
+// PanelSection
//============================================================================
var IPython = (function (IPython) {
View
8 IPython/frontend/html/notebook/static/js/savewidget.js
@@ -1,6 +1,12 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
-// Cell
+// SaveWidget
//============================================================================
var IPython = (function (IPython) {
View
6 IPython/frontend/html/notebook/static/js/textcell.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// TextCell
View
6 IPython/frontend/html/notebook/static/js/utils.js
@@ -1,3 +1,9 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2008-2011 The IPython Development Team
+//
+// Distributed under the terms of the BSD License. The full license is in
+// the file COPYING, distributed as part of this software.
+//----------------------------------------------------------------------------
//============================================================================
// Utilities
View
13 IPython/frontend/html/notebook/tests/test_kernelsession.py
@@ -3,7 +3,6 @@
from unittest import TestCase
from IPython.frontend.html.notebook.kernelmanager import KernelManager
-from IPython.frontend.html.notebook.sessionmanager import SessionManagerRunningError
class TestKernelManager(TestCase):
@@ -24,16 +23,4 @@ def test_km_lifecycle(self):
self.assert_('hb_port' in port_dict)
km.get_kernel_process(kid)
- def test_session_manager(self):
- km = KernelManager()
- kid = km.start_kernel()
- sm = km.create_session_manager(kid)
- self.assert_(sm._running)
- sm.stop()
- self.assert_(not sm._running)
- sm.start()
- self.assertRaises(SessionManagerRunningError, sm.start)
- sm.get_iopub_stream()
- sm.get_shell_stream()
- sm.session
View
28 IPython/frontend/html/notebook/zmqhttp.py
@@ -1,9 +1,29 @@
-import json
+"""Unfinished code for ZMQ/HTTP bridging. We use WebSockets instead.
-from tornado import web
+Authors:
+
+* Brian Granger
+"""
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
+
+import json
import logging
+from tornado import web
+
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
class ZMQHandler(web.RequestHandler):
@@ -74,7 +94,3 @@ def post(self, *args, **kwargs):
stream.send_json(msg)
stream.on_recv(self._handle_msgs)
-
-
-
-
View
21 IPython/nbformat/current.py
@@ -1,3 +1,21 @@
+"""The official API for working with notebooks in the current format version.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
+
import json
from xml.etree import ElementTree as ET
import re
@@ -11,6 +29,9 @@
parse_filename
)
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
current_nbformat = 2
View
12 IPython/nbformat/v1/__init__.py
@@ -1,3 +1,15 @@
+"""The main module for the v1 notebook format."""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
from .nbbase import (
NotebookNode,
View
11 IPython/nbformat/v1/convert.py
@@ -1,4 +1,15 @@
+"""Convert notebook to the v1 format."""
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
def convert_to_this_nbformat(nb, orig_version=None):
raise ValueError('Cannot convert to v1 notebook format')
View
21 IPython/nbformat/v1/nbbase.py
@@ -1,10 +1,29 @@
-"""The basic dict based notebook format."""
+"""The basic dict based notebook format.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
import pprint
import uuid
from IPython.utils.ipstruct import Struct
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
class NotebookNode(Struct):
pass
View
21 IPython/nbformat/v1/nbjson.py
@@ -1,10 +1,29 @@
-"""Read and write notebooks in JSON format."""
+"""Read and write notebooks in JSON format.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
from base64 import encodestring
from .rwbase import NotebookReader, NotebookWriter
from .nbbase import from_dict
import json
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
class JSONReader(NotebookReader):
View
21 IPython/nbformat/v1/rwbase.py
@@ -1,5 +1,26 @@
+"""Base classes and function for readers and writers.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
+
from base64 import encodestring, decodestring
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
class NotebookReader(object):
View
20 IPython/nbformat/v2/__init__.py
@@ -1,3 +1,20 @@
+"""The main API for the v2 notebook format.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
from .nbbase import (
NotebookNode,
@@ -18,6 +35,9 @@
from .convert import convert_to_this_nbformat
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
def parse_filename(fname):
"""Parse a notebook filename.
View
32 IPython/nbformat/v2/convert.py
@@ -1,8 +1,39 @@
+"""Code for converting notebooks to and from the v2 format.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
+
from .nbbase import (
new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output
)
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
+
def convert_to_this_nbformat(nb, orig_version=1):
+ """Convert a notebook to the v2 format.
+
+ Parameters
+ ----------
+ nb : NotebookNode
+ The Python representation of the notebook to convert.
+ orig_version : int
+ The original version of the notebook to convert.
+ """
if orig_version == 1:
newnb = new_notebook()
ws = new_worksheet()
@@ -17,4 +48,3 @@ def convert_to_this_nbformat(nb, orig_version=1):
else:
raise ValueError('Cannot convert a notebook from v%s to v2' % orig_version)
-
View
26 IPython/nbformat/v2/nbbase.py
@@ -1,10 +1,34 @@
-"""The basic dict based notebook format."""
+"""The basic dict based notebook format.
+
+The Python representation of a notebook is a nested structure of
+dictionary subclasses that support attribute access
+(IPython.utils.ipstruct.Struct). The functions in this module are merely
+helpers to build the structs in the right form.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
import pprint
import uuid
from IPython.utils.ipstruct import Struct
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
class NotebookNode(Struct):
pass
View
21 IPython/nbformat/v2/nbjson.py
@@ -1,10 +1,29 @@
-"""Read and write notebooks in JSON format."""
+"""Read and write notebooks in JSON format.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
from base64 import encodestring
from .nbbase import from_dict
from .rwbase import NotebookReader, NotebookWriter, base64_decode
import json
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
class BytesEncoder(json.JSONEncoder):
def default(self, obj):
View
21 IPython/nbformat/v2/nbpy.py
@@ -1,8 +1,27 @@
-"""Read and write notebooks as regular .py files."""
+"""Read and write notebooks as regular .py files.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
from .rwbase import NotebookReader, NotebookWriter
from .nbbase import new_code_cell, new_text_cell, new_worksheet, new_notebook
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
class PyReaderError(Exception):
pass
View
22 IPython/nbformat/v2/nbxml.py
@@ -1,4 +1,20 @@
-"""Read and write notebook files as XML."""
+"""Read and write notebook files as XML.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
from base64 import encodestring, decodestring
from xml.etree import ElementTree as ET
@@ -8,6 +24,10 @@
new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output
)
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
+
def indent(elem, level=0):
i = "\n" + level*" "
if len(elem):
View
24 IPython/nbformat/v2/rwbase.py
@@ -1,6 +1,28 @@
+"""Base classes and utilities for readers and writers.
+
+Authors:
+
+* Brian Granger
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) 2008-2011 The IPython Development Team
+#
+# Distributed under the terms of the BSD License. The full license is in
+# the file COPYING, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
+
from base64 import encodestring, decodestring
import pprint
+#-----------------------------------------------------------------------------
+# Code
+#-----------------------------------------------------------------------------
+
def base64_decode(nb):
"""Base64 encode all bytes objects in the notebook."""
for ws in nb.worksheets:
@@ -26,6 +48,7 @@ def base64_encode(nb):
class NotebookReader(object):
+ """A class for reading notebooks."""
def reads(self, s, **kwargs):
"""Read a notebook from a string."""
@@ -37,6 +60,7 @@ def read(self, fp, **kwargs):
class NotebookWriter(object):
+ """A class for writing notebooks."""
def writes(self, nb, **kwargs):
"""Write a notebook to a string."""
View
7 IPython/scripts/ipython-notebook
@@ -1,7 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-from IPython.frontend.html.notebook import notebookapp
-
-notebookapp.launch_new_instance()
-
Please sign in to comment.
Something went wrong with that request. Please try again.