def __init__(self, execer, ctx=None, shell_type=None, **kwargs): """ Parameters ---------- execer : Execer An execer instance capable of running xonsh code. ctx : Mapping, optional The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly. shell_type : str, optional The shell type to start, such as 'readline', 'prompt_toolkit', or 'random'. """ self.execer = execer self.ctx = {} if ctx is None else ctx env = builtins.__xonsh_env__ # build history backend before creating shell builtins.__xonsh_history__ = hist = xhm.construct_history( env=env.detype(), ts=[time.time(), None], locked=True) # pick a valid shell -- if no shell is specified by the user, # shell type is pulled from env if shell_type is None: shell_type = env.get('SHELL_TYPE') if shell_type == 'none': # This bricks interactive xonsh # Can happen from the use of .xinitrc, .xsession, etc shell_type = 'best' if shell_type == 'best' or shell_type is None: shell_type = best_shell_type() elif shell_type == 'random': shell_type = random.choice(('readline', 'prompt_toolkit')) if shell_type == 'prompt_toolkit': if not has_prompt_toolkit(): warnings.warn('prompt_toolkit is not available, using ' 'readline instead.') shell_type = 'readline' elif not ptk_version_is_supported(): warnings.warn('prompt-toolkit version < v1.0.0 is not ' 'supported. Please update prompt-toolkit. Using ' 'readline instead.') shell_type = 'readline' self.shell_type = env['SHELL_TYPE'] = shell_type # actually make the shell if shell_type == 'none': from xonsh.base_shell import BaseShell as shell_class elif shell_type == 'prompt_toolkit': from xonsh.ptk.shell import PromptToolkitShell as shell_class elif shell_type == 'readline': from xonsh.readline_shell import ReadlineShell as shell_class else: raise XonshError('{} is not recognized as a shell type'.format( shell_type)) self.shell = shell_class(execer=self.execer, ctx=self.ctx, **kwargs) # allows history garbage collector to start running if hist.gc is not None: hist.gc.wait_for_shell = False
def choose_shell_type(init_shell_type=None, env=None): # pick a valid shell -- if no shell is specified by the user, # shell type is pulled from env # extracted for testability shell_type = init_shell_type if shell_type is None and env: shell_type = env.get("SHELL_TYPE") if shell_type == "none": # This bricks interactive xonsh # Can happen from the use of .xinitrc, .xsession, etc # odd logic. We don't override if shell.__init__( shell_type="none"), # only if it come from environment? shell_type = "best" shell_type = Shell.shell_type_aliases.get(shell_type, shell_type) if shell_type == "best" or shell_type is None: shell_type = best_shell_type() elif env and env.get("TERM", "") == "dumb": shell_type = "dumb" elif shell_type == "random": shell_type = random.choice(("readline", "prompt_toolkit")) if shell_type == "prompt_toolkit": if not has_prompt_toolkit(): use_vended_prompt_toolkit() elif not ptk_above_min_supported(): warnings.warn( "Installed prompt-toolkit version < v{}.{}.{} is not ". format(*minimum_required_ptk_version) + "supported. Falling back to the builtin prompt-toolkit.") use_vended_prompt_toolkit() if init_shell_type in ("ptk1", "prompt_toolkit1"): warnings.warn( "$SHELL_TYPE='{}' now deprecated, please update your run control file'" .format(init_shell_type)) return shell_type
def __init__(self, execer, ctx=None, shell_type=None, **kwargs): """ Parameters ---------- execer : Execer An execer instance capable of running xonsh code. ctx : Mapping, optional The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly. shell_type : str, optional The shell type to start, such as 'readline', 'prompt_toolkit', or 'random'. """ self.execer = execer self.ctx = {} if ctx is None else ctx env = builtins.__xonsh_env__ # build history backend before creating shell builtins.__xonsh_history__ = hist = xhm.construct_history( env=env.detype(), ts=[time.time(), None], locked=True) # pick a valid shell -- if no shell is specified by the user, # shell type is pulled from env if shell_type is None: shell_type = env.get('SHELL_TYPE') if shell_type == 'none': # This bricks interactive xonsh # Can happen from the use of .xinitrc, .xsession, etc shell_type = 'best' if shell_type == 'best' or shell_type is None: shell_type = best_shell_type() elif shell_type == 'random': shell_type = random.choice(('readline', 'prompt_toolkit')) if shell_type == 'prompt_toolkit': if not has_prompt_toolkit(): warnings.warn('prompt_toolkit is not available, using ' 'readline instead.') shell_type = 'readline' elif not ptk_version_is_supported(): warnings.warn('prompt-toolkit version < v1.0.0 is not ' 'supported. Please update prompt-toolkit. Using ' 'readline instead.') shell_type = 'readline' self.shell_type = env['SHELL_TYPE'] = shell_type # actually make the shell if shell_type == 'none': from xonsh.base_shell import BaseShell as shell_class elif shell_type == 'prompt_toolkit': from xonsh.ptk.shell import PromptToolkitShell as shell_class elif shell_type == 'readline': from xonsh.readline_shell import ReadlineShell as shell_class else: raise XonshError( '{} is not recognized as a shell type'.format(shell_type)) self.shell = shell_class(execer=self.execer, ctx=self.ctx, **kwargs) # allows history garbage collector to start running if hist.gc is not None: hist.gc.wait_for_shell = False
def __init__(self, ctx=None, shell_type=None, config=None, rc=None, **kwargs): """ Parameters ---------- ctx : Mapping, optional The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly. shell_type : str, optional The shell type to start, such as 'readline', 'prompt_toolkit', or 'random'. config : str, optional Path to configuration file. rc : list of str, optional Sequence of paths to run control files. """ self.login = kwargs.get('login', True) self.stype = shell_type self._init_environ(ctx, config, rc, kwargs.get('scriptcache', True), kwargs.get('cacheall', False)) env = builtins.__xonsh_env__ # pick a valid shell -- if no shell is specified by the user, # shell type is pulled from env if shell_type is None: shell_type = env.get('SHELL_TYPE') if shell_type == 'best' or shell_type is None: shell_type = best_shell_type() elif shell_type == 'random': shell_type = random.choice(('readline', 'prompt_toolkit')) if shell_type == 'prompt_toolkit': if not has_prompt_toolkit(): warnings.warn('prompt_toolkit is not available, using ' 'readline instead.') shell_type = 'readline' elif not ptk_version_is_supported(): warnings.warn('prompt-toolkit version < v1.0.0 is not ' 'supported. Please update prompt-toolkit. Using ' 'readline instead.') shell_type = 'readline' env['SHELL_TYPE'] = shell_type # actually make the shell if shell_type == 'none': from xonsh.base_shell import BaseShell as shell_class elif shell_type == 'prompt_toolkit': from xonsh.ptk.shell import PromptToolkitShell as shell_class elif shell_type == 'readline': from xonsh.readline_shell import ReadlineShell as shell_class else: raise XonshError( '{} is not recognized as a shell type'.format(shell_type)) self.shell = shell_class(execer=self.execer, ctx=self.ctx, **kwargs) # allows history garbace colector to start running builtins.__xonsh_history__.gc.wait_for_shell = False
def __init__(self, ctx=None, shell_type=None, config=None, rc=None, **kwargs): """ Parameters ---------- ctx : Mapping, optional The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly. shell_type : str, optional The shell type to start, such as 'readline', 'prompt_toolkit', or 'random'. config : str, optional Path to configuration file. rc : list of str, optional Sequence of paths to run control files. """ self.login = kwargs.get('login', True) self.stype = shell_type self._init_environ(ctx, config, rc, kwargs.get('scriptcache', True), kwargs.get('cacheall', False)) env = builtins.__xonsh_env__ # pick a valid shell if shell_type is not None: 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 elif shell_type == 'random': shell_type = random.choice(('readline', 'prompt_toolkit')) if shell_type == 'prompt_toolkit': if not has_prompt_toolkit(): warn( 'prompt_toolkit is not available, using readline instead.') shell_type = env['SHELL_TYPE'] = 'readline' # actually make the shell if shell_type == 'none': from xonsh.base_shell import BaseShell as shell_class elif shell_type == 'prompt_toolkit': if ptk_version_info()[:2] < (0, 57) or \ ptk_version() == '<0.57': # TODO: remove in future msg = ('prompt-toolkit version < v0.57 and may not work as ' 'expected. Please update.') warn(msg, RuntimeWarning) from xonsh.ptk.shell import PromptToolkitShell as shell_class elif shell_type == 'readline': from xonsh.readline_shell import ReadlineShell as shell_class else: raise XonshError( '{} is not recognized as a shell type'.format(shell_type)) self.shell = shell_class(execer=self.execer, ctx=self.ctx, **kwargs) # allows history garbace colector to start running builtins.__xonsh_history__.gc.wait_for_shell = False
def __init__(self, ctx=None, shell_type=None, config=None, rc=None, **kwargs): """ Parameters ---------- ctx : Mapping, optional The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly. shell_type : str, optional The shell type to start, such as 'readline', 'prompt_toolkit', or 'random'. config : str, optional Path to configuration file. rc : list of str, optional Sequence of paths to run control files. """ self.login = kwargs.get('login', True) self.stype = shell_type self._init_environ(ctx, config, rc, kwargs.get('scriptcache', True), kwargs.get('cacheall', False)) env = builtins.__xonsh_env__ # pick a valid shell -- if no shell is specified by the user, # shell type is pulled from env if shell_type is None: shell_type = env.get('SHELL_TYPE') if shell_type == 'best' or shell_type is None: shell_type = best_shell_type() elif shell_type == 'random': shell_type = random.choice(('readline', 'prompt_toolkit')) if shell_type == 'prompt_toolkit': if not has_prompt_toolkit(): warnings.warn('prompt_toolkit is not available, using ' 'readline instead.') shell_type = 'readline' elif not ptk_version_is_supported(): warnings.warn('prompt-toolkit version < v1.0.0 is not ' 'supported. Please update prompt-toolkit. Using ' 'readline instead.') shell_type = 'readline' env['SHELL_TYPE'] = shell_type # actually make the shell if shell_type == 'none': from xonsh.base_shell import BaseShell as shell_class elif shell_type == 'prompt_toolkit': from xonsh.ptk.shell import PromptToolkitShell as shell_class elif shell_type == 'readline': from xonsh.readline_shell import ReadlineShell as shell_class else: raise XonshError('{} is not recognized as a shell type'.format( shell_type)) self.shell = shell_class(execer=self.execer, ctx=self.ctx, **kwargs) # allows history garbace colector to start running builtins.__xonsh_history__.gc.wait_for_shell = False
def __init__(self, ctx=None, shell_type=None, config=None, rc=None, **kwargs): """ Parameters ---------- ctx : Mapping, optional The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly. shell_type : str, optional The shell type to start, such as 'readline', 'prompt_toolkit', or 'random'. config : str, optional Path to configuration file. rc : list of str, optional Sequence of paths to run control files. """ self.login = kwargs.get('login', True) self.stype = shell_type self._init_environ(ctx, config, rc, kwargs.get('scriptcache', True), kwargs.get('cacheall', False)) env = builtins.__xonsh_env__ # pick a valid shell if shell_type is not None: 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 elif shell_type == 'random': shell_type = random.choice(('readline', 'prompt_toolkit')) if shell_type == 'prompt_toolkit': if not has_prompt_toolkit(): warn('prompt_toolkit is not available, using readline instead.') shell_type = env['SHELL_TYPE'] = 'readline' # actually make the shell if shell_type == 'none': from xonsh.base_shell import BaseShell as shell_class elif shell_type == 'prompt_toolkit': if ptk_version_info()[:2] < (0, 57) or \ ptk_version() == '<0.57': # TODO: remove in future msg = ('prompt-toolkit version < v0.57 and may not work as ' 'expected. Please update.') warn(msg, RuntimeWarning) from xonsh.ptk.shell import PromptToolkitShell as shell_class elif shell_type == 'readline': from xonsh.readline_shell import ReadlineShell as shell_class else: raise XonshError('{} is not recognized as a shell type'.format( shell_type)) self.shell = shell_class(execer=self.execer, ctx=self.ctx, **kwargs) # allows history garbace colector to start running builtins.__xonsh_history__.gc.wait_for_shell = False
def __init__(self, ctx=None, shell_type=None, config=None, rc=None, **kwargs): """ Parameters ---------- ctx : Mapping, optional The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly. shell_type : str, optional The shell type to start, such as 'readline', 'prompt_toolkit', or 'random'. config : str, optional Path to configuration file. rc : list of str, optional Sequence of paths to run control files. """ self.login = kwargs.get("login", True) self.stype = shell_type self._init_environ(ctx, config, rc, kwargs.get("scriptcache", True), kwargs.get("cacheall", False)) env = builtins.__xonsh_env__ # pick a valid shell -- if no shell is specified by the user, # shell type is pulled from env if shell_type is None: shell_type = env.get("SHELL_TYPE") if shell_type == "best" or shell_type is None: shell_type = best_shell_type() elif shell_type == "random": shell_type = random.choice(("readline", "prompt_toolkit")) if shell_type == "prompt_toolkit": if not has_prompt_toolkit(): warn("prompt_toolkit is not available, using readline instead.") shell_type = "readline" env["SHELL_TYPE"] = shell_type # actually make the shell if shell_type == "none": from xonsh.base_shell import BaseShell as shell_class elif shell_type == "prompt_toolkit": if ptk_version_info()[:2] < (1, 0): msg = ( "prompt-toolkit version < v1.0.0 is not supported, " "xonsh may not work as expected. Please update." ) warn(msg, RuntimeWarning) from xonsh.ptk.shell import PromptToolkitShell as shell_class elif shell_type == "readline": from xonsh.readline_shell import ReadlineShell as shell_class else: raise XonshError("{} is not recognized as a shell type".format(shell_type)) self.shell = shell_class(execer=self.execer, ctx=self.ctx, **kwargs) # allows history garbace colector to start running builtins.__xonsh_history__.gc.wait_for_shell = False
def expand_gray_colors_for_cmd_exe(style_map): """ Expand the style's gray scale color range. All gray scale colors has a tendency to map to the same default GRAY in cmd.exe. """ modified_style = {} stype = builtins.__xonsh_env__.get('SHELL_TYPE') if (not ON_WINDOWS or (stype not in ('prompt_toolkit', 'best')) or (stype == 'best' and not has_prompt_toolkit())): return modified_style for token, idx, rgb in _get_color_indexes(style_map): if idx == 7 and rgb: if sum(rgb) <= 306: # Equal and below '#666666 is reset to dark gray modified_style[token] = '#444444' elif sum(rgb) >= 408: # Equal and above 0x888888 is reset to white modified_style[token] = '#ffffff' return modified_style
def COORD(): if platform.has_prompt_toolkit(): # turns out that PTK has a separate ctype wrapper # for this struct and also wraps similar function calls # we need to use the same struct to prevent clashes. import prompt_toolkit.win32_types return prompt_toolkit.win32_types.COORD class _COORD(ctypes.Structure): """Struct from the winapi, representing coordinates in the console. Attributes ---------- X : int Column position Y : int Row position """ _fields_ = [("X", SHORT), ("Y", SHORT)] return _COORD
def CONSOLE_SCREEN_BUFFER_INFO(): if platform.has_prompt_toolkit(): # turns out that PTK has a separate ctype wrapper # for this struct and also wraps kernel32.GetConsoleScreenBufferInfo # we need to use the same struct to prevent clashes. import prompt_toolkit.win32_types return prompt_toolkit.win32_types.CONSOLE_SCREEN_BUFFER_INFO # Otherwise we should wrap it ourselves COORD() # force COORD to load class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): """Struct from in wincon.h. See Windows API docs for more details. Attributes ---------- dwSize : COORD Size of dwCursorPosition : COORD Current cursor location. wAttributes : WORD Flags for screen buffer. srWindow : SMALL_RECT Actual size of screen dwMaximumWindowSize : COORD Maximum window scrollback size. """ _fields_ = [ ("dwSize", COORD), ("dwCursorPosition", COORD), ("wAttributes", WORD), ("srWindow", SMALL_RECT), ("dwMaximumWindowSize", COORD), ] return _CONSOLE_SCREEN_BUFFER_INFO
def intensify_colors_for_cmd_exe(style_map, replace_colors=None): """Returns a modified style to where colors that maps to dark colors are replaced with brighter versions. Also expands the range used by the gray colors """ modified_style = {} stype = builtins.__xonsh_env__.get('SHELL_TYPE') if (not ON_WINDOWS or (stype not in ('prompt_toolkit', 'best')) or (stype == 'best' and not has_prompt_toolkit())): return modified_style if replace_colors is None: replace_colors = { 1: '#44ffff', # subst blue with bright cyan 2: '#44ff44', # subst green with bright green 4: '#ff4444', # subst red with bright red 5: '#ff44ff', # subst magenta with bright magenta 6: '#ffff44', # subst yellow with bright yellow 9: '#00aaaa', # subst intense blue (hard to read) # with dark cyan (which is readable) } for token, idx, _ in _get_color_indexes(style_map): if idx in replace_colors: modified_style[token] = replace_colors[idx] return modified_style
def intensify_colors_for_cmd_exe(style_map, replace_colors=None): """Returns a modified style to where colors that maps to dark colors are replaced with brighter versions. Also expands the range used by the gray colors """ modified_style = {} stype = builtins.__xonsh_env__.get('SHELL_TYPE') if (not ON_WINDOWS or (stype not in ('prompt_toolkit', 'best')) or (stype == 'best' and not has_prompt_toolkit())): return modified_style if replace_colors is None: replace_colors = {1: '#44ffff', # subst blue with bright cyan 2: '#44ff44', # subst green with bright green 4: '#ff4444', # subst red with bright red 5: '#ff44ff', # subst magenta with bright magenta 6: '#ffff44', # subst yellow with bright yellow 9: '#00aaaa', # subst intense blue (hard to read) # with dark cyan (which is readable) } for token, idx, _ in _get_color_indexes(style_map): if idx in replace_colors: modified_style[token] = replace_colors[idx] return modified_style
def __init__(self, execer, ctx=None, shell_type=None, **kwargs): """ Parameters ---------- execer : Execer An execer instance capable of running xonsh code. ctx : Mapping, optional The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly. shell_type : str, optional The shell type to start, such as 'readline', 'prompt_toolkit1', or 'random'. """ self.execer = execer self.ctx = {} if ctx is None else ctx env = builtins.__xonsh__.env # build history backend before creating shell builtins.__xonsh__.history = hist = xhm.construct_history( env=env.detype(), ts=[time.time(), None], locked=True) # pick a valid shell -- if no shell is specified by the user, # shell type is pulled from env if shell_type is None: shell_type = env.get("SHELL_TYPE") if shell_type == "none": # This bricks interactive xonsh # Can happen from the use of .xinitrc, .xsession, etc shell_type = "best" shell_type = self.shell_type_aliases.get(shell_type, shell_type) if shell_type == "best" or shell_type is None: shell_type = best_shell_type() elif env.get("TERM", "") == "dumb": shell_type = "dumb" elif shell_type == "random": shell_type = random.choice(("readline", "prompt_toolkit")) if shell_type == "prompt_toolkit": if not has_prompt_toolkit(): warnings.warn("prompt_toolkit is not available, using " "readline instead.") shell_type = "readline" elif not ptk_above_min_supported(): warnings.warn("prompt-toolkit version < v1.0.0 is not " "supported. Please update prompt-toolkit. Using " "readline instead.") shell_type = "readline" else: shell_type = ptk_shell_type() self.shell_type = env["SHELL_TYPE"] = shell_type # actually make the shell if shell_type == "none": from xonsh.base_shell import BaseShell as shell_class elif shell_type == "prompt_toolkit2": from xonsh.ptk2.shell import PromptToolkit2Shell as shell_class elif shell_type == "prompt_toolkit1": from xonsh.ptk.shell import PromptToolkitShell as shell_class elif shell_type == "readline": from xonsh.readline_shell import ReadlineShell as shell_class elif shell_type == "jupyter": from xonsh.jupyter_shell import JupyterShell as shell_class elif shell_type == "dumb": from xonsh.dumb_shell import DumbShell as shell_class else: raise XonshError( "{} is not recognized as a shell type".format(shell_type)) self.shell = shell_class(execer=self.execer, ctx=self.ctx, **kwargs) # allows history garbage collector to start running if hist.gc is not None: hist.gc.wait_for_shell = False
def __init__(self, execer, ctx=None, shell_type=None, **kwargs): """ Parameters ---------- execer : Execer An execer instance capable of running xonsh code. ctx : Mapping, optional The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly. shell_type : str, optional The shell type to start, such as 'readline', 'prompt_toolkit1', or 'random'. """ self.execer = execer self.ctx = {} if ctx is None else ctx env = builtins.__xonsh__.env # build history backend before creating shell builtins.__xonsh__.history = hist = xhm.construct_history( env=env.detype(), ts=[time.time(), None], locked=True ) # pick a valid shell -- if no shell is specified by the user, # shell type is pulled from env if shell_type is None: shell_type = env.get("SHELL_TYPE") if shell_type == "none": # This bricks interactive xonsh # Can happen from the use of .xinitrc, .xsession, etc shell_type = "best" shell_type = self.shell_type_aliases.get(shell_type, shell_type) if shell_type == "best" or shell_type is None: shell_type = best_shell_type() elif env.get("TERM", "") == "dumb": shell_type = "dumb" elif shell_type == "random": shell_type = random.choice(("readline", "prompt_toolkit")) if shell_type == "prompt_toolkit": if not has_prompt_toolkit(): warnings.warn( "prompt_toolkit is not available, using " "readline instead." ) shell_type = "readline" elif not ptk_above_min_supported(): warnings.warn( "prompt-toolkit version < v1.0.0 is not " "supported. Please update prompt-toolkit. Using " "readline instead." ) shell_type = "readline" else: shell_type = ptk_shell_type() self.shell_type = env["SHELL_TYPE"] = shell_type # actually make the shell if shell_type == "none": from xonsh.base_shell import BaseShell as shell_class elif shell_type == "prompt_toolkit2": from xonsh.ptk2.shell import PromptToolkit2Shell as shell_class elif shell_type == "prompt_toolkit1": from xonsh.ptk.shell import PromptToolkitShell as shell_class elif shell_type == "readline": from xonsh.readline_shell import ReadlineShell as shell_class elif shell_type == "jupyter": from xonsh.jupyter_shell import JupyterShell as shell_class elif shell_type == "dumb": from xonsh.dumb_shell import DumbShell as shell_class else: raise XonshError("{} is not recognized as a shell type".format(shell_type)) self.shell = shell_class(execer=self.execer, ctx=self.ctx, **kwargs) # allows history garbage collector to start running if hist.gc is not None: hist.gc.wait_for_shell = False
import string import ctypes import builtins import subprocess import threading import traceback from warnings import warn from contextlib import contextmanager from collections import OrderedDict, Sequence, Set # adding further imports from xonsh modules is discouraged to avoid cirular # dependencies from xonsh.platform import (has_prompt_toolkit, scandir, win_unicode_console, DEFAULT_ENCODING, ON_LINUX, ON_WINDOWS, PYTHON_VERSION_INFO) if has_prompt_toolkit(): import prompt_toolkit else: prompt_toolkit = None IS_SUPERUSER = ctypes.windll.shell32.IsUserAnAdmin() != 0 if ON_WINDOWS else os.getuid() == 0 class XonshError(Exception): pass class DefaultNotGivenType(object): """Singleton for representing when no default value is given."""
import string import ctypes import builtins import subprocess import threading import traceback from warnings import warn from contextlib import contextmanager from collections import OrderedDict, Sequence, Set # adding further imports from xonsh modules is discouraged to avoid cirular # dependencies from xonsh.platform import (has_prompt_toolkit, win_unicode_console, DEFAULT_ENCODING, ON_LINUX, ON_WINDOWS) if has_prompt_toolkit(): import prompt_toolkit else: prompt_toolkit = None IS_SUPERUSER = ctypes.windll.shell32.IsUserAnAdmin() != 0 if ON_WINDOWS else os.getuid() == 0 class XonshError(Exception): pass class DefaultNotGivenType(object): """Singleton for representing when no default value is given."""