|
1 | 1 | """
|
2 |
| -Utilities for managing IPython 3/4 compat. |
| 2 | +Utilities for managing compat between notebook versions. |
3 | 3 | """
|
4 |
| -import IPython |
| 4 | +import notebook |
| 5 | +if notebook.version_info[0] >= 6: # noqa |
| 6 | + raise ImportError("Jupyter Notebook versions 6 and up are not supported.") |
5 | 7 |
|
6 |
| -IPY_MAJOR = IPython.version_info[0] |
7 |
| -if IPY_MAJOR < 3: |
8 |
| - raise ImportError("IPython version %d is not supported." % IPY_MAJOR) |
| 8 | +from traitlets.config import Config |
| 9 | +from notebook.services.contents.checkpoints import ( |
| 10 | + Checkpoints, |
| 11 | + GenericCheckpointsMixin, |
| 12 | +) |
| 13 | +from notebook.services.contents.filemanager import FileContentsManager |
| 14 | +from notebook.services.contents.filecheckpoints import ( |
| 15 | + GenericFileCheckpoints |
| 16 | +) |
| 17 | +from notebook.services.contents.manager import ContentsManager |
| 18 | +from notebook.services.contents.tests.test_manager import ( |
| 19 | + TestContentsManager |
| 20 | +) |
| 21 | +from notebook.services.contents.tests.test_contents_api import ( |
| 22 | + APITest |
| 23 | +) |
| 24 | +from notebook.tests.launchnotebook import assert_http_error |
| 25 | +from notebook.utils import to_os_path |
| 26 | +from nbformat import from_dict, reads, writes |
| 27 | +from nbformat.v4.nbbase import ( |
| 28 | + new_code_cell, |
| 29 | + new_markdown_cell, |
| 30 | + new_notebook, |
| 31 | + new_raw_cell, |
| 32 | +) |
| 33 | +from nbformat.v4.rwbase import strip_transient |
| 34 | +from traitlets import ( |
| 35 | + Any, |
| 36 | + Bool, |
| 37 | + Dict, |
| 38 | + Instance, |
| 39 | + Integer, |
| 40 | + HasTraits, |
| 41 | + Unicode, |
| 42 | +) |
9 | 43 |
|
10 |
| -IPY3 = (IPY_MAJOR == 3) |
11 |
| - |
12 |
| -if IPY3: |
13 |
| - from IPython.config import Config |
14 |
| - from IPython.html.services.contents.manager import ContentsManager |
15 |
| - from IPython.html.services.contents.checkpoints import ( |
16 |
| - Checkpoints, |
17 |
| - GenericCheckpointsMixin, |
18 |
| - ) |
19 |
| - from IPython.html.services.contents.filemanager import FileContentsManager |
20 |
| - from IPython.html.services.contents.filecheckpoints import ( |
21 |
| - GenericFileCheckpoints |
22 |
| - ) |
23 |
| - from IPython.html.services.contents.tests.test_manager import ( |
24 |
| - TestContentsManager |
25 |
| - ) |
26 |
| - from IPython.html.services.contents.tests.test_contents_api import ( |
27 |
| - APITest |
28 |
| - ) |
29 |
| - from IPython.html.tests.launchnotebook import assert_http_error |
30 |
| - from IPython.html.utils import to_os_path |
31 |
| - from IPython.nbformat import from_dict, reads, writes |
32 |
| - from IPython.nbformat.v4.nbbase import ( |
33 |
| - new_code_cell, |
34 |
| - new_markdown_cell, |
35 |
| - new_notebook, |
36 |
| - new_raw_cell, |
37 |
| - ) |
38 |
| - from IPython.nbformat.v4.rwbase import strip_transient |
39 |
| - from IPython.utils.traitlets import ( |
40 |
| - Any, |
41 |
| - Bool, |
42 |
| - Dict, |
43 |
| - Instance, |
44 |
| - Integer, |
45 |
| - HasTraits, |
46 |
| - Unicode, |
47 |
| - ) |
48 |
| -else: |
49 |
| - import notebook |
50 |
| - if notebook.version_info[0] >= 6: |
51 |
| - raise ImportError("Notebook versions 6 and up are not supported.") |
52 |
| - |
53 |
| - from traitlets.config import Config |
54 |
| - from notebook.services.contents.checkpoints import ( |
55 |
| - Checkpoints, |
56 |
| - GenericCheckpointsMixin, |
57 |
| - ) |
58 |
| - from notebook.services.contents.filemanager import FileContentsManager |
59 |
| - from notebook.services.contents.filecheckpoints import ( |
60 |
| - GenericFileCheckpoints |
61 |
| - ) |
62 |
| - from notebook.services.contents.manager import ContentsManager |
63 |
| - from notebook.services.contents.tests.test_manager import ( |
64 |
| - TestContentsManager |
65 |
| - ) |
66 |
| - from notebook.services.contents.tests.test_contents_api import ( |
67 |
| - APITest |
68 |
| - ) |
69 |
| - from notebook.tests.launchnotebook import assert_http_error |
70 |
| - from notebook.utils import to_os_path |
71 |
| - from nbformat import from_dict, reads, writes |
72 |
| - from nbformat.v4.nbbase import ( |
73 |
| - new_code_cell, |
74 |
| - new_markdown_cell, |
75 |
| - new_notebook, |
76 |
| - new_raw_cell, |
77 |
| - ) |
78 |
| - from nbformat.v4.rwbase import strip_transient |
79 |
| - from traitlets import ( |
80 |
| - Any, |
81 |
| - Bool, |
82 |
| - Dict, |
83 |
| - Instance, |
84 |
| - Integer, |
85 |
| - HasTraits, |
86 |
| - Unicode, |
87 |
| - ) |
88 | 44 |
|
89 | 45 | __all__ = [
|
90 | 46 | 'APITest',
|
|
0 commit comments