Show More
@@ -54,27 +54,19 b' class NotebookManager(LoggingConfigurable):' | |||
|
54 | 54 | Returns |
|
55 | 55 | ------- |
|
56 | 56 | name : string or None |
|
57 |
the filename of the notebook, or None if not a .ipynb exte |
|
|
58 |
path : string |
|
|
57 | the filename of the notebook, or None if not a .ipynb extension | |
|
58 | path : string | |
|
59 | 59 | the path to the directory which contains the notebook |
|
60 | 60 | """ |
|
61 | 61 | names = notebook_path.split('/') |
|
62 | if len(names) > 1: | |
|
62 | ||
|
63 | 63 |
|
|
64 | 64 |
|
|
65 | 65 |
|
|
66 |
|
|
|
67 | else: | |
|
68 | name = None | |
|
69 | path = notebook_path+'/' | |
|
70 | else: | |
|
71 | name = names[0] | |
|
72 | if name.endswith(".ipynb"): | |
|
73 | name = name | |
|
74 | path = None | |
|
66 | path = "/".join(names[:-1]) + '/' | |
|
75 | 67 |
|
|
76 | 68 |
|
|
77 |
|
|
|
69 | path = "/".join(names) + '/' | |
|
78 | 70 | return name, path |
|
79 | 71 | |
|
80 | 72 | def url_encode(self, path): |
@@ -41,9 +41,16 b' class TestNotebookManager(TestCase):' | |||
|
41 | 41 | self.assertEqual(name, None) |
|
42 | 42 | self.assertEqual(path, 'hello/') |
|
43 | 43 | |
|
44 | name, path = nm.named_notebook_path('/') | |
|
45 | self.assertEqual(name, None) | |
|
46 | ||
|
44 | 47 | name, path = nm.named_notebook_path('hello.ipynb') |
|
45 | 48 | self.assertEqual(name, 'hello.ipynb') |
|
46 |
self.assertEqual(path, |
|
|
49 | self.assertEqual(path, '/') | |
|
50 | ||
|
51 | name, path = nm.named_notebook_path('/hello.ipynb') | |
|
52 | self.assertEqual(name, 'hello.ipynb') | |
|
53 | self.assertEqual(path, '/') | |
|
47 | 54 | |
|
48 | 55 | name, path = nm.named_notebook_path('/this/is/a/path/hello.ipynb') |
|
49 | 56 | self.assertEqual(name, 'hello.ipynb') |
General Comments 0
You need to be logged in to leave comments.
Login now