Show More
@@ -86,11 +86,11 b' class FileNotebookManager(NotebookManager):' | |||
|
86 | 86 | def list_notebooks(self, path): |
|
87 | 87 | """List all notebooks in the notebook dir.""" |
|
88 | 88 | notebook_names = self.get_notebook_names(path) |
|
89 |
notebook |
|
|
89 | notebooks = [] | |
|
90 | 90 | for name in notebook_names: |
|
91 | 91 | model = self.notebook_model(name, path, content=False) |
|
92 |
notebook |
|
|
93 |
return notebook |
|
|
92 | notebooks.append(model) | |
|
93 | return notebooks | |
|
94 | 94 | |
|
95 | 95 | def change_notebook(self, data, notebook_name, notebook_path=None): |
|
96 | 96 | """Changes notebook""" |
@@ -73,11 +73,13 b' class NotebookManager(LoggingConfigurable):' | |||
|
73 | 73 | return name, path |
|
74 | 74 | |
|
75 | 75 | def url_encode(self, path): |
|
76 |
parts = path.split( |
|
|
76 | parts = os.path.split(path) | |
|
77 | #parts = path.split('/') | |
|
77 | 78 | return os.path.join(*[quote(p) for p in parts]) |
|
78 | 79 | |
|
79 | 80 | def url_decode(self, path): |
|
80 |
parts = path.split( |
|
|
81 | parts = os.path.split(path) | |
|
82 | #parts = path.split('/') | |
|
81 | 83 | return os.path.join(*[unquote(p) for p in parts]) |
|
82 | 84 | |
|
83 | 85 | def _notebook_dir_changed(self, new): |
@@ -127,11 +129,6 b' class NotebookManager(LoggingConfigurable):' | |||
|
127 | 129 | """ |
|
128 | 130 | raise NotImplementedError('must be implemented in a subclass') |
|
129 | 131 | |
|
130 | ||
|
131 | def notebook_exists(self, notebook_path): | |
|
132 | """Does a notebook exist?""" | |
|
133 | ||
|
134 | ||
|
135 | 132 | def notebook_model(self, notebook_name, notebook_path=None, content=True): |
|
136 | 133 | """ Creates the standard notebook model """ |
|
137 | 134 | last_modified, contents = self.read_notebook_object(notebook_name, notebook_path) |
@@ -61,4 +61,30 b' class TestNotebookManager(TestCase):' | |||
|
61 | 61 | self.assertEqual(name, 'hello.ipynb') |
|
62 | 62 | self.assertEqual(path, '/path/without/leading/slash/') |
|
63 | 63 | |
|
64 | def test_url_encode(self): | |
|
65 | nm = NotebookManager() | |
|
66 | ||
|
67 | # changes path or notebook name with special characters to url encoding | |
|
68 | # these tests specifically encode paths with spaces | |
|
69 | path = nm.url_encode('/this is a test/for spaces/') | |
|
70 | self.assertEqual(path, '/this%20is%20a%20test/for%20spaces/') | |
|
71 | ||
|
72 | path = nm.url_encode('notebook with space.ipynb') | |
|
73 | self.assertEqual(path, 'notebook%20with%20space.ipynb') | |
|
74 | ||
|
75 | path = nm.url_encode('/path with a/notebook and space.ipynb') | |
|
76 | self.assertEqual(path, '/path%20with%20a/notebook%20and%20space.ipynb') | |
|
77 | ||
|
78 | def test_url_decode(self): | |
|
79 | nm = NotebookManager() | |
|
80 | ||
|
81 | # decodes a url string to a plain string | |
|
82 | # these tests decode paths with spaces | |
|
83 | path = nm.url_decode('/this%20is%20a%20test/for%20spaces/') | |
|
84 | self.assertEqual(path, '/this is a test/for spaces/') | |
|
85 | ||
|
86 | path = nm.url_decode('notebook%20with%20space.ipynb') | |
|
87 | self.assertEqual(path, 'notebook with space.ipynb') | |
|
64 | 88 | |
|
89 | path = nm.url_decode('/path%20with%20a/notebook%20and%20space.ipynb') | |
|
90 | self.assertEqual(path, '/path with a/notebook and space.ipynb') |
General Comments 0
You need to be logged in to leave comments.
Login now