bring back lazy loading of best shell type

This commit is contained in:
adam j hartz 2016-05-23 08:23:05 -04:00
parent 9aedc9ca21
commit 1c50c9c335
2 changed files with 8 additions and 9 deletions

View file

@ -93,13 +93,12 @@ def ptk_version_info():
return None
BEST_SHELL_TYPE = None
""" The 'best' available shell type, either 'prompt_toollit' or 'readline'. """
if ON_WINDOWS or has_prompt_toolkit():
BEST_SHELL_TYPE = 'prompt_toolkit'
else:
BEST_SHELL_TYPE = 'readline'
@lru_cache(1)
def best_shell_type():
if ON_WINDOWS or has_prompt_toolkit():
return 'prompt_toolkit'
else:
return 'readline'
@lru_cache(1)

View file

@ -7,7 +7,7 @@ from warnings import warn
from xonsh import xontribs
from xonsh.environ import xonshrc_context
from xonsh.execer import Execer
from xonsh.platform import (BEST_SHELL_TYPE, has_prompt_toolkit, ptk_version,
from xonsh.platform import (best_shell_type, has_prompt_toolkit, ptk_version,
ptk_version_info)
from xonsh.tools import XonshError
@ -48,7 +48,7 @@ class Shell(object):
env['SHELL_TYPE'] = shell_type
shell_type = env.get('SHELL_TYPE')
if shell_type == 'best' or shell_type is None:
shell_type = BEST_SHELL_TYPE
shell_type = best_shell_type()
elif shell_type == 'random':
shell_type = random.choice(('readline', 'prompt_toolkit'))
if shell_type == 'prompt_toolkit':