Skip to content

Commit 5e6c56f

Browse files
committed
Checks for having python shells
1 parent 477ec68 commit 5e6c56f

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

tmuxp/shell.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,45 @@
1313
logger = logging.getLogger(__name__)
1414

1515

16-
def launch(shell=None, best=True, use_pythonrc=False, **kwargs):
16+
def has_ipython():
17+
try:
18+
from IPython import start_ipython # NOQA F841
19+
except ImportError:
20+
try:
21+
from IPython.Shell import IPShell # NOQA F841
22+
except ImportError:
23+
return False
24+
25+
return True
26+
27+
28+
def has_ptpython():
29+
try:
30+
from ptpython.repl import embed, run_config # NOQA F841
31+
except ImportError:
32+
try:
33+
from prompt_toolkit.contrib.repl import embed, run_config # NOQA F841
34+
except ImportError:
35+
return False
36+
37+
return True
38+
39+
40+
def has_ptipython():
41+
try:
42+
from ptpython.ipython import embed # NOQA F841
43+
from ptpython.repl import run_config # NOQA F841
44+
except ImportError:
45+
try:
46+
from prompt_toolkit.contrib.ipython import embed # NOQA F841
47+
from prompt_toolkit.contrib.repl import run_config # NOQA F841
48+
except ImportError:
49+
return False
50+
51+
return True
52+
53+
54+
def launch(shell='best', use_pythonrc=False, **kwargs):
1755
import code
1856

1957
import libtmux

0 commit comments

Comments
 (0)