Skip to content

Commit

Permalink
Accept kernel name with * and ? in language module #192
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Feb 9, 2019
1 parent 4a55cc2 commit 8a6cf20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
package_dir={'': 'src'},
python_requires='>=3.6',
install_requires=[
'sos>=0.18.2',
'sos>=0.18.7',
'nbformat',
'nbconvert>=5.1.1',
'ipython',
Expand Down
6 changes: 6 additions & 0 deletions src/sos_notebook/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Distributed under the terms of the 3-clause BSD License.

import contextlib
import fnmatch
import logging
import os
import subprocess
Expand Down Expand Up @@ -146,6 +147,11 @@ def __init__(self, kernel):
self._kernel_list.append(
subkernel(name=lan_map[spec][0], kernel=spec, language=lan_map[spec][0],
color=lan_map[spec][1], options=lan_map[spec][2]))
elif any(fnmatch.fnmatch(spec, x) for x in lan_map.keys()):
matched = [y for x,y in lan_map.items() if fnmatch.fnmatch(spec, x)][0]
self._kernel_list.append(
subkernel(name=matched[0], kernel=spec, language=matched[0],
color=matched[1], options=matched[2]))
else:
# undefined language also use default theme color
self._kernel_list.append(subkernel(name=spec, kernel=spec, language=km.get_kernel_spec(spec).language))
Expand Down

0 comments on commit 8a6cf20

Please sign in to comment.