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