mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Docstring and comment spelling corrections
A number of common spelling typos found within various docstrings and comments found within source code files have been identified and resolved.
This commit is contained in:
parent
12e2fb80cc
commit
2abb24f4f6
57 changed files with 161 additions and 160 deletions
|
@ -31,5 +31,5 @@ pylint:
|
|||
|
||||
mccabe:
|
||||
disable:
|
||||
- MC0000 # not Py3k compatabile
|
||||
- MC0000 # not Py3k compatible
|
||||
- MC0001 # silly cyclomatic complexity
|
||||
|
|
2
docs/_static/console_colors.reg
vendored
2
docs/_static/console_colors.reg
vendored
|
@ -1,6 +1,6 @@
|
|||
Windows Registry Editor Version 5.00
|
||||
|
||||
; Registry file that maps the solarized palette to the 16 avaliable colors
|
||||
; Registry file that maps the solarized palette to the 16 available colors
|
||||
; in a Windows command prompt. Note, hex values in the table are RGB but byte
|
||||
; ordering of a DWORD is BGR, e.g. "ColorTable<##>"=dword:00<B><G><R>
|
||||
;
|
||||
|
|
2
setup.py
2
setup.py
|
@ -314,7 +314,7 @@ def main():
|
|||
)
|
||||
if HAVE_SETUPTOOLS:
|
||||
# WARNING!!! Do not use setuptools 'console_scripts'
|
||||
# It validates the depenendcies (of which we have none) everytime the
|
||||
# It validates the dependencies (of which we have none) every time the
|
||||
# 'xonsh' command is run. This validation adds ~0.2 sec. to the startup
|
||||
# time of xonsh - for every single xonsh run. This prevents us from
|
||||
# reaching the goal of a startup time of < 0.1 sec. So never ever write
|
||||
|
|
|
@ -140,7 +140,7 @@ def test_uncpushd_push_to_same_share(xonsh_builtins, shares_setup):
|
|||
assert len(DIRSTACK) == 2
|
||||
|
||||
dirstack.popd([])
|
||||
assert os.path.isdir(TEMP_DRIVE[0] + '\\'), "Temp drived not unmapped till last reference removed"
|
||||
assert os.path.isdir(TEMP_DRIVE[0] + '\\'), "Temp drive not unmapped till last reference removed"
|
||||
dirstack.popd([])
|
||||
assert owd.casefold() == os.getcwd().casefold(), "popd returned cwd to expected dir"
|
||||
assert len(_unc_tempDrives) == 0
|
||||
|
|
|
@ -63,12 +63,12 @@ def test_bad_indent():
|
|||
check_parse(code)
|
||||
|
||||
def test_good_rhs_subproc():
|
||||
# nonsense but parsebale
|
||||
# nonsense but parsable
|
||||
code = 'str().split() | ![grep exit]\n'
|
||||
assert(code)
|
||||
|
||||
def test_bad_rhs_subproc():
|
||||
# nonsense but unparsebale
|
||||
# nonsense but unparsable
|
||||
code = 'str().split() | grep exit\n'
|
||||
with pytest.raises(SyntaxError):
|
||||
check_parse(code)
|
||||
|
|
|
@ -10,7 +10,7 @@ from xonsh.ptk.history import PromptToolkitHistory
|
|||
|
||||
@pytest.fixture
|
||||
def history_obj():
|
||||
"""Instatiate `PromptToolkitHistory` and append a line string"""
|
||||
"""Instantiate `PromptToolkitHistory` and append a line string"""
|
||||
hist = PromptToolkitHistory(load_prev=False)
|
||||
hist.append('line10')
|
||||
return hist
|
||||
|
|
|
@ -404,7 +404,7 @@ def showcmd(args, stdin=None):
|
|||
|
||||
def detect_xip_alias():
|
||||
"""
|
||||
Determines the correct invokation to get xonsh's pip
|
||||
Determines the correct invocation to get xonsh's pip
|
||||
"""
|
||||
if not getattr(sys, 'executable', None):
|
||||
return lambda args, stdin=None: ("", "Sorry, unable to run pip on your system (missing sys.executable)", 1)
|
||||
|
|
|
@ -19,7 +19,7 @@ def ansi_partial_color_format(template, style='default', cmap=None, hide=False):
|
|||
template : str
|
||||
The template string, potentially with color names.
|
||||
style : str, optional
|
||||
Sytle name to look up color map from.
|
||||
Style name to look up color map from.
|
||||
cmap : dict, optional
|
||||
A color map to use, this will prevent the color map from being
|
||||
looked up via the style name.
|
||||
|
|
|
@ -160,7 +160,7 @@ def xonsh_call(name, args, lineno=None, col=None):
|
|||
|
||||
|
||||
def isdescendable(node):
|
||||
"""Deteremines whether or not a node is worth visiting. Currently only
|
||||
"""Determines whether or not a node is worth visiting. Currently only
|
||||
UnaryOp and BoolOp nodes are visited.
|
||||
"""
|
||||
return isinstance(node, (UnaryOp, BoolOp))
|
||||
|
@ -177,7 +177,7 @@ class CtxAwareTransformer(NodeTransformer):
|
|||
"""Parameters
|
||||
----------
|
||||
parser : xonsh.Parser
|
||||
A parse instance to try to parse suprocess statements with.
|
||||
A parse instance to try to parse subprocess statements with.
|
||||
"""
|
||||
super(CtxAwareTransformer, self).__init__()
|
||||
self.parser = parser
|
||||
|
|
|
@ -213,10 +213,10 @@ class _TeeStd(io.TextIOBase):
|
|||
|
||||
|
||||
class Tee:
|
||||
"""Class that merges tee'd stdout and stderr into a single strea,.
|
||||
"""Class that merges tee'd stdout and stderr into a single stream.
|
||||
|
||||
This represents what a user would actually see on the command line.
|
||||
This class as the same interface as io.TextIOWrapper, except that
|
||||
This class has the same interface as io.TextIOWrapper, except that
|
||||
the buffer is optional.
|
||||
"""
|
||||
# pylint is a stupid about counting public methods when using inheritance.
|
||||
|
@ -480,7 +480,7 @@ class BaseShell(object):
|
|||
kernel32.SetConsoleTitleW(t)
|
||||
else:
|
||||
with open(1, 'wb', closefd=False) as f:
|
||||
# prevent xonsh from answering interative questions
|
||||
# prevent xonsh from answering interactive questions
|
||||
# on the next command by writing the title
|
||||
f.write("\x1b]0;{0}\x07".format(t).encode())
|
||||
f.flush()
|
||||
|
@ -506,15 +506,15 @@ class BaseShell(object):
|
|||
return p
|
||||
|
||||
def format_color(self, string, hide=False, force_string=False, **kwargs):
|
||||
"""Formats the colors in a string. This base implmentation colors based
|
||||
on ANSI color codes
|
||||
"""Formats the colors in a string. This base implementation's colors are
|
||||
based on ANSI color codes.
|
||||
"""
|
||||
style = builtins.__xonsh_env__.get('XONSH_COLOR_STYLE')
|
||||
return ansi_partial_color_format(string, hide=hide, style=style)
|
||||
|
||||
def print_color(self, string, hide=False, **kwargs):
|
||||
"""Prints a string in color. This base implmentation will color based
|
||||
ANSI color codes if a string was given as input. If a list of token
|
||||
"""Prints a string in color. This base implementation's colors are based
|
||||
on ANSI color codes if a string was given as input. If a list of token
|
||||
pairs is given, it will color based on pygments, if available. If
|
||||
pygments is not available, it will print a colorless string.
|
||||
"""
|
||||
|
|
|
@ -191,8 +191,8 @@ def get_script_subproc_command(fname, args):
|
|||
if not os.access(fname, os.X_OK):
|
||||
raise PermissionError
|
||||
if ON_POSIX and not os.access(fname, os.R_OK):
|
||||
# on some systems, some importnat programs (e.g. sudo) will have
|
||||
# execute permissions but not read/write permisions. This enables
|
||||
# on some systems, some important programs (e.g. sudo) will have
|
||||
# execute permissions but not read/write permissions. This enables
|
||||
# things with the SUID set to be run. Needs to come before _is_binary()
|
||||
# is called, because that function tries to read the file.
|
||||
return [fname] + args
|
||||
|
@ -348,7 +348,7 @@ def no_pg_xonsh_preexec_fn():
|
|||
|
||||
|
||||
class SubprocSpec:
|
||||
"""A container for specifiying how a subprocess command should be
|
||||
"""A container for specifying how a subprocess command should be
|
||||
executed.
|
||||
"""
|
||||
|
||||
|
@ -381,7 +381,7 @@ class SubprocSpec:
|
|||
args : list of str
|
||||
Arguments as originally supplied.
|
||||
alias : list of str, callable, or None
|
||||
The alias that was reolved for this command, if any.
|
||||
The alias that was resolved for this command, if any.
|
||||
binary_loc : str or None
|
||||
Path to binary to execute.
|
||||
is_proxy : bool
|
||||
|
@ -549,7 +549,7 @@ class SubprocSpec:
|
|||
|
||||
def _fix_null_cmd_bytes(self):
|
||||
# Popen does not accept null bytes in its input commands.
|
||||
# that doesn;t stop some subproces from using them. Here we
|
||||
# That doesn't stop some subprocess' from using them. Here we
|
||||
# escape them just in case.
|
||||
cmd = self.cmd
|
||||
for i in range(len(cmd)):
|
||||
|
@ -562,8 +562,8 @@ class SubprocSpec:
|
|||
@classmethod
|
||||
def build(kls, cmd, *, cls=subprocess.Popen, **kwargs):
|
||||
"""Creates an instance of the subprocess command, with any
|
||||
modifcations and adjustments based on the actual cmd that
|
||||
was recieved.
|
||||
modifications and adjustments based on the actual cmd that
|
||||
was received.
|
||||
"""
|
||||
# modifications that do not alter cmds may come before creating instance
|
||||
spec = kls(cmd, cls=cls, **kwargs)
|
||||
|
@ -662,7 +662,7 @@ class SubprocSpec:
|
|||
cls = ProcProxyThread if thable else ProcProxy
|
||||
self.cls = cls
|
||||
self.threadable = thable
|
||||
# also check capturablity, while we are here
|
||||
# also check capturability, while we are here
|
||||
cpable = getattr(alias, '__xonsh_capturable__', self.captured)
|
||||
self.captured = cpable
|
||||
|
||||
|
@ -781,7 +781,7 @@ def cmds_to_specs(cmds, captured=False):
|
|||
specs[-1].background = True
|
||||
else:
|
||||
raise XonshError('unrecognized redirect {0!r}'.format(redirect))
|
||||
# Apply boundry conditions
|
||||
# Apply boundary conditions
|
||||
_update_last_spec(specs[-1])
|
||||
return specs
|
||||
|
||||
|
@ -942,7 +942,7 @@ def convert_macro_arg(raw_arg, kind, glbs, locs, *, name='<arg>',
|
|||
Parameters
|
||||
----------
|
||||
raw_arg : str
|
||||
The str reprensetaion of the macro argument.
|
||||
The str representation of the macro argument.
|
||||
kind : object
|
||||
A flag or type representing how to convert the argument.
|
||||
glbs : Mapping
|
||||
|
@ -966,7 +966,7 @@ def convert_macro_arg(raw_arg, kind, glbs, locs, *, name='<arg>',
|
|||
if isinstance(kind, str):
|
||||
kind = _convert_kind_flag(kind)
|
||||
if kind is str or kind is None:
|
||||
return raw_arg # short circut since there is nothing else to do
|
||||
return raw_arg # short circuit since there is nothing else to do
|
||||
# select from kind and convert
|
||||
execer = builtins.__xonsh_execer__
|
||||
filename = macroname + '(' + name + ')'
|
||||
|
@ -1035,9 +1035,9 @@ def call_macro(f, raw_args, glbs, locs):
|
|||
f : callable object
|
||||
The function that is called as ``f(*args)``.
|
||||
raw_args : tuple of str
|
||||
The str reprensetaion of arguments of that were passed into the
|
||||
The str representation of arguments of that were passed into the
|
||||
macro. These strings will be parsed, compiled, evaled, or left as
|
||||
a string dependending on the annotations of f.
|
||||
a string depending on the annotations of f.
|
||||
glbs : Mapping
|
||||
The globals from the call site.
|
||||
locs : Mapping or None
|
||||
|
@ -1110,7 +1110,7 @@ def enter_macro(obj, raw_block, glbs, locs):
|
|||
raw_block : str
|
||||
The str of the block that is the context body.
|
||||
This string will be parsed, compiled, evaled, or left as
|
||||
a string dependending on the return annotation of obj.__enter__.
|
||||
a string depending on the return annotation of obj.__enter__.
|
||||
glbs : Mapping
|
||||
The globals from the context site.
|
||||
locs : Mapping or None
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
a command will be able to be run in the background.
|
||||
|
||||
A background predictor is a function that accepts a single argument list
|
||||
and returns whethere or not the process can be run in the background (returns
|
||||
and returns whether or not the process can be run in the background (returns
|
||||
True) or must be run the foreground (returns False).
|
||||
"""
|
||||
import os
|
||||
|
@ -39,7 +39,7 @@ class CommandsCache(cabc.Mapping):
|
|||
def __iter__(self):
|
||||
for cmd, (path, is_alias) in self.all_commands.items():
|
||||
if ON_WINDOWS and path is not None:
|
||||
# All comand keys are stored in uppercase on Windows.
|
||||
# All command keys are stored in uppercase on Windows.
|
||||
# This ensures the original command name is returned.
|
||||
cmd = pathbasename(path)
|
||||
yield cmd
|
||||
|
@ -223,7 +223,7 @@ class CommandsCache(cabc.Mapping):
|
|||
return predict_true
|
||||
|
||||
def default_predictor_readbin(self, name, cmd0, timeout, failure):
|
||||
"""Make a defautt predictor by
|
||||
"""Make a default predictor by
|
||||
analyzing the content of the binary. Should only works on POSIX.
|
||||
Return failure if the analysis fails.
|
||||
"""
|
||||
|
@ -297,7 +297,7 @@ def SHELL_PREDICTOR_PARSER():
|
|||
|
||||
|
||||
def predict_shell(args):
|
||||
"""Precict the backgroundability of the normal shell interface, which
|
||||
"""Predict the backgroundability of the normal shell interface, which
|
||||
comes down to whether it is being run in subproc mode.
|
||||
"""
|
||||
ns, _ = SHELL_PREDICTOR_PARSER.parse_known_args(args)
|
||||
|
@ -319,7 +319,7 @@ def HELP_VER_PREDICTOR_PARSER():
|
|||
|
||||
|
||||
def predict_help_ver(args):
|
||||
"""Precict the backgroundability of commands that have help & version
|
||||
"""Predict the backgroundability of commands that have help & version
|
||||
switches: -h, --help, -v, -V, --version. If either of these options is
|
||||
present, the command is assumed to print to stdout normally and is therefore
|
||||
threadable. Otherwise, the command is assumed to not be threadable.
|
||||
|
|
|
@ -256,7 +256,7 @@ def bash_completions(prefix, line, begidx, endidx, env=None, paths=None,
|
|||
endidx : int
|
||||
The index in line that prefix ends on.
|
||||
env : Mapping, optional
|
||||
The environment dict to execute the Bash suprocess in.
|
||||
The environment dict to execute the Bash subprocess in.
|
||||
paths : list or tuple of str or None, optional
|
||||
This is a list (or tuple) of strings that specifies where the
|
||||
``bash_completion`` script may be found. The first valid path will
|
||||
|
|
|
@ -52,7 +52,7 @@ def greenline(line):
|
|||
|
||||
|
||||
def highlighted_ndiff(a, b):
|
||||
"""Returns a highlited string, with bold charaters where different."""
|
||||
"""Returns a highlighted string, with bold characters where different."""
|
||||
s = ''
|
||||
sm = difflib.SequenceMatcher()
|
||||
sm.set_seqs(a, b)
|
||||
|
|
|
@ -107,7 +107,7 @@ def _unc_unmap_temp_drive(left_drive, cwd):
|
|||
if left_drive not in _unc_tempDrives: # if not one we've mapped, don't unmap it
|
||||
return
|
||||
|
||||
for p in DIRSTACK + [cwd]: # if still in use , don't aunmap it.
|
||||
for p in DIRSTACK + [cwd]: # if still in use , don't unmap it.
|
||||
if p.casefold().startswith(left_drive):
|
||||
return
|
||||
|
||||
|
@ -161,10 +161,10 @@ def _try_cdpath(apath):
|
|||
# In bash if a CDPATH is set, an unqualified local folder
|
||||
# is considered after all CDPATHs, example:
|
||||
# CDPATH=$HOME/src (with src/xonsh/ inside)
|
||||
# $ cd xonsh -> src/xonsh (whith xonsh/xonsh)
|
||||
# $ cd xonsh -> src/xonsh (with xonsh/xonsh)
|
||||
# a second $ cd xonsh has no effects, to move in the nested xonsh
|
||||
# in bash a full $ cd ./xonsh is needed.
|
||||
# In xonsh a relative folder is allways preferred.
|
||||
# In xonsh a relative folder is always preferred.
|
||||
env = builtins.__xonsh_env__
|
||||
cdpaths = env.get('CDPATH')
|
||||
for cdp in cdpaths:
|
||||
|
|
|
@ -772,7 +772,7 @@ class Env(cabc.MutableMapping):
|
|||
|
||||
* PATH: any variable whose name ends in PATH is a list of strings.
|
||||
* XONSH_HISTORY_SIZE: this variable is an (int | float, str) tuple.
|
||||
* LC_* (locale categories): locale catergory names get/set the Python
|
||||
* LC_* (locale categories): locale category names get/set the Python
|
||||
locale via locale.getlocale() and locale.setlocale() functions.
|
||||
|
||||
An Env instance may be converted to an untyped version suitable for
|
||||
|
@ -831,7 +831,7 @@ class Env(cabc.MutableMapping):
|
|||
|
||||
def replace_env(self):
|
||||
"""Replaces the contents of os_environ with a detyped version
|
||||
of the xonsh environement.
|
||||
of the xonsh environment.
|
||||
"""
|
||||
if self._orig_env is None:
|
||||
self._orig_env = dict(os_environ)
|
||||
|
@ -840,7 +840,7 @@ class Env(cabc.MutableMapping):
|
|||
|
||||
def undo_replace_env(self):
|
||||
"""Replaces the contents of os_environ with a detyped version
|
||||
of the xonsh environement.
|
||||
of the xonsh environment.
|
||||
"""
|
||||
if self._orig_env is not None:
|
||||
os_environ.clear()
|
||||
|
@ -874,7 +874,7 @@ class Env(cabc.MutableMapping):
|
|||
return vd
|
||||
|
||||
def help(self, key):
|
||||
"""Get information about a specific enviroment variable."""
|
||||
"""Get information about a specific environment variable."""
|
||||
vardocs = self.get_docs(key)
|
||||
width = min(79, os.get_terminal_size()[0])
|
||||
docstr = '\n'.join(textwrap.wrap(vardocs.docstr, width=width))
|
||||
|
|
|
@ -24,7 +24,7 @@ def debug_level():
|
|||
return builtins.__xonsh_env__.get('XONSH_DEBUG')
|
||||
# FIXME: Under py.test, return 1(?)
|
||||
else:
|
||||
return 0 # Optimize for speed, not guarenteed correctness
|
||||
return 0 # Optimize for speed, not guaranteed correctness
|
||||
|
||||
|
||||
class AbstractEvent(collections.abc.MutableSet, abc.ABC):
|
||||
|
@ -267,7 +267,7 @@ class EventManager:
|
|||
----------
|
||||
name : str
|
||||
The name of the event, eg "on_precommand"
|
||||
species : sublcass of AbstractEvent
|
||||
species : subclass of AbstractEvent
|
||||
The type to turn the event in to.
|
||||
"""
|
||||
if isinstance(species, str):
|
||||
|
|
|
@ -65,7 +65,7 @@ class Execer(object):
|
|||
# Parsing actually happens in a couple of phases. The first is a
|
||||
# shortcut for a context-free parser. Normally, all subprocess
|
||||
# lines should be wrapped in $(), to indicate that they are a
|
||||
# subproc. But that would be super annoying. Unfortnately, Python
|
||||
# subproc. But that would be super annoying. Unfortunately, Python
|
||||
# mode - after indentation - is whitespace agnostic while, using
|
||||
# the Python token, subproc mode is whitespace aware. That is to say,
|
||||
# in Python mode "ls -l", "ls-l", and "ls - l" all parse to the
|
||||
|
@ -187,7 +187,7 @@ class Execer(object):
|
|||
if len(line.strip()) == 0:
|
||||
# whitespace only lines are not valid syntax in Python's
|
||||
# interactive mode='single', who knew?! Just ignore them.
|
||||
# this might cause actual sytax errors to have bad line
|
||||
# this might cause actual syntax errors to have bad line
|
||||
# numbers reported, but should only affect interactive mode
|
||||
del lines[idx]
|
||||
last_error_line = last_error_col = -1
|
||||
|
|
|
@ -88,7 +88,7 @@ fi
|
|||
echo ${namefile}"""
|
||||
|
||||
|
||||
# mapping of shell name alises to keys in other lookup dictionaries.
|
||||
# mapping of shell name aliases to keys in other lookup dictionaries.
|
||||
@lazyobject
|
||||
def CANON_SHELL_NAMES():
|
||||
return {
|
||||
|
@ -197,7 +197,7 @@ def foreign_shell_data(shell, interactive=True, login=False, envcmd=None,
|
|||
aliascmd : str or None, optional
|
||||
The command to generate alias output with.
|
||||
extra_args : tuple of str, optional
|
||||
Addtional command line options to pass into the shell.
|
||||
Additional command line options to pass into the shell.
|
||||
currenv : tuple of items or None, optional
|
||||
Manual override for the current environment.
|
||||
safe : bool, optional
|
||||
|
@ -248,7 +248,7 @@ def foreign_shell_data(shell, interactive=True, login=False, envcmd=None,
|
|||
env : dict
|
||||
Dictionary of shell's environment. (None if the subproc command fails)
|
||||
aliases : dict
|
||||
Dictionary of shell's alaiases, this includes foreign function
|
||||
Dictionary of shell's aliases, this includes foreign function
|
||||
wrappers.(None if the subproc command fails)
|
||||
"""
|
||||
cmd = [shell]
|
||||
|
@ -425,9 +425,9 @@ class ForeignShellFunctionAlias(object):
|
|||
filename : str
|
||||
Where the function is defined, path to source.
|
||||
sourcer : str or None, optional
|
||||
Command to source foreing files with.
|
||||
Command to source foreign files with.
|
||||
extra_args : tuple of str, optional
|
||||
Addtional command line options to pass into the shell.
|
||||
Additional command line options to pass into the shell.
|
||||
"""
|
||||
sourcer = DEFAULT_SOURCERS.get(shell, 'source') if sourcer is None \
|
||||
else sourcer
|
||||
|
|
|
@ -103,8 +103,8 @@ class History:
|
|||
Parameters
|
||||
----------
|
||||
cmd: dict
|
||||
A dict contains informations of a command. It should contains
|
||||
the following keys like ``inp``, ``rtn``, ``ts`` etc.
|
||||
A dict contains information on a command. It should contain
|
||||
the following keys, like ``inp``, ``rtn``, ``ts`` &etc.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
@ -136,7 +136,7 @@ class History:
|
|||
Parameters
|
||||
----------
|
||||
size: None or tuple of a int and a string
|
||||
Detemines the size and units of what would be allowed to remain.
|
||||
Determines the size and units of what would be allowed to remain.
|
||||
blocking: bool
|
||||
If set blocking, then wait until gc action finished.
|
||||
"""
|
||||
|
|
|
@ -360,7 +360,7 @@ class JsonHistory(History):
|
|||
----------
|
||||
at_exit : bool, optional
|
||||
Whether the JsonHistoryFlusher should act as a thread in the
|
||||
background, or execute immeadiately and block.
|
||||
background, or execute immediately and block.
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
@ -383,7 +383,7 @@ class JsonHistory(History):
|
|||
"""
|
||||
Returns all history as found in XONSH_DATA_DIR.
|
||||
|
||||
yeild format: {'inp': cmd, 'rtn': 0, ...}
|
||||
yield format: {'inp': cmd, 'rtn': 0, ...}
|
||||
"""
|
||||
while self.gc and self.gc.is_alive():
|
||||
time.sleep(0.011) # gc sleeps for 0.01 secs, sleep a beat longer
|
||||
|
|
|
@ -32,7 +32,7 @@ def _xh_sqlite_create_history_table(cursor):
|
|||
"""Create Table for history items.
|
||||
|
||||
Columns:
|
||||
info - JSON formated, reserved for future extension.
|
||||
info - JSON formatted, reserved for future extension.
|
||||
"""
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS xonsh_history
|
||||
|
|
|
@ -236,7 +236,7 @@ class XonshImportEventHook(MetaPathFinder):
|
|||
|
||||
|
||||
class XonshImportEventLoader(Loader):
|
||||
"""A class that dispatches loader calls to another loader and fires relevent
|
||||
"""A class that dispatches loader calls to another loader and fires relevant
|
||||
xonsh events.
|
||||
"""
|
||||
|
||||
|
@ -261,11 +261,11 @@ class XonshImportEventLoader(Loader):
|
|||
return rtn
|
||||
|
||||
def load_module(self, fullname):
|
||||
"""Legacy module loading, provided for backwards compatability."""
|
||||
"""Legacy module loading, provided for backwards compatibility."""
|
||||
return self.loader.load_module(fullname)
|
||||
|
||||
def module_repr(self, module):
|
||||
"""Legacy module repr, provided for backwards compatability."""
|
||||
"""Legacy module repr, provided for backwards compatibility."""
|
||||
return self.loader.module_repr(module)
|
||||
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ def call_tip(oinfo, format_call=True):
|
|||
Returns
|
||||
-------
|
||||
call_info : None, str or (str, dict) tuple.
|
||||
When format_call is True, the whole call information is formattted as a
|
||||
When format_call is True, the whole call information is formatted as a
|
||||
single string. Otherwise, the object's name and its argspec dict are
|
||||
returned. If no call information is available, None is returned.
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class LazyObject(object):
|
|||
provided context (typically the globals of the call site) with the
|
||||
given name.
|
||||
|
||||
For example, you can prevent the compilation of a regular expreession
|
||||
For example, you can prevent the compilation of a regular expression
|
||||
until it is actually used::
|
||||
|
||||
DOT = LazyObject((lambda: re.compile('.')), globals(), 'DOT')
|
||||
|
@ -150,7 +150,7 @@ class LazyDict(cabc.MutableMapping):
|
|||
----------
|
||||
loaders : Mapping of keys to functions with no arguments
|
||||
A mapping of loader function that performs the actual value
|
||||
construction upon acces.
|
||||
construction upon access.
|
||||
ctx : Mapping
|
||||
Context to replace the LazyDict instance in
|
||||
with the the fully loaded mapping.
|
||||
|
@ -335,7 +335,7 @@ def load_module_in_background(name, package=None, debug='DEBUG', env=None,
|
|||
os.environ otherwise.
|
||||
replacements : Mapping or None, optional
|
||||
Dictionary mapping fully qualified module names (eg foo.bar.baz) that
|
||||
import the lazily loaded moudle, with the variable name in that
|
||||
import the lazily loaded module, with the variable name in that
|
||||
module. For example, suppose that foo.bar imports module a as b,
|
||||
this dict is then {'foo.bar': 'b'}.
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ class Lexer(object):
|
|||
t = self.token()
|
||||
|
||||
def split(self, s):
|
||||
"""Splits a string into a list of strings which are whitepace-separated
|
||||
"""Splits a string into a list of strings which are whitespace-separated
|
||||
tokens.
|
||||
"""
|
||||
vals = []
|
||||
|
|
|
@ -5,7 +5,7 @@ from xonsh.platform import LIBC
|
|||
|
||||
|
||||
def sysctlbyname(name, return_str=True):
|
||||
"""Gets a sysctrl value by name. If return_str is true, this will return
|
||||
"""Gets a sysctl value by name. If return_str is true, this will return
|
||||
a string representation, else it will return the raw value.
|
||||
"""
|
||||
# forked from https://gist.github.com/pudquick/581a71425439f2cf8f09
|
||||
|
|
|
@ -220,7 +220,7 @@ class XonshMode(enum.Enum):
|
|||
|
||||
def start_services(shell_kwargs):
|
||||
"""Starts up the essential services in the proper order.
|
||||
This returns the envrionment instance as a convenience.
|
||||
This returns the environment instance as a convenience.
|
||||
"""
|
||||
install_import_hooks()
|
||||
# create execer, which loads builtins
|
||||
|
@ -246,7 +246,7 @@ def start_services(shell_kwargs):
|
|||
|
||||
|
||||
def premain(argv=None):
|
||||
"""Setup for main xonsh entry point, returns parsed arguments."""
|
||||
"""Setup for main xonsh entry point. Returns parsed arguments."""
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
setup_timings()
|
||||
|
|
|
@ -190,7 +190,7 @@ def empty_list_if_newline(x):
|
|||
|
||||
def lopen_loc(x):
|
||||
"""Extracts the line and column number for a node that may have anb opening
|
||||
parenthesis, brace, or braket.
|
||||
parenthesis, brace, or bracket.
|
||||
"""
|
||||
lineno = x._lopen_lineno if hasattr(x, '_lopen_lineno') else x.lineno
|
||||
col = x._lopen_col if hasattr(x, '_lopen_col') else x.col_offset
|
||||
|
@ -390,7 +390,7 @@ class BaseParser(object):
|
|||
setattr(self.__class__, listfunc.__name__, listfunc)
|
||||
|
||||
def _tok_rule(self, rulename):
|
||||
"""For a rule name, creates a rule that retuns the corresponding token.
|
||||
"""For a rule name, creates a rule that returns the corresponding token.
|
||||
'_tok' is appended to the rule name.
|
||||
"""
|
||||
|
||||
|
@ -1437,7 +1437,7 @@ class BaseParser(object):
|
|||
self.p_nodedent_base.__func__.__doc__ = doc
|
||||
|
||||
def p_nodedent_base(self, p):
|
||||
# see above attachament function
|
||||
# see above attachment function
|
||||
pass
|
||||
|
||||
def p_nodedent_any(self, p):
|
||||
|
@ -1471,7 +1471,7 @@ class BaseParser(object):
|
|||
self.p_nonewline_base.__func__.__doc__ = doc
|
||||
|
||||
def p_nonewline_base(self, p):
|
||||
# see above attachament function
|
||||
# see above attachment function
|
||||
pass
|
||||
|
||||
def p_nonewline_any(self, p):
|
||||
|
@ -1979,7 +1979,7 @@ class BaseParser(object):
|
|||
self.p_nocloser_base.__func__.__doc__ = doc
|
||||
|
||||
def p_nocloser_base(self, p):
|
||||
# see above attachament function
|
||||
# see above attachment function
|
||||
pass
|
||||
|
||||
def p_nocloser_any(self, p):
|
||||
|
@ -2098,13 +2098,13 @@ class BaseParser(object):
|
|||
# The following grammar rules are no-ops because we don't need to glue the
|
||||
# source code back together piece-by-piece. Instead, we simply look for
|
||||
# top-level commas and record their positions. With these positions and
|
||||
# the bounding parantheses !() positions we can use the source_slice()
|
||||
# the bounding parenthesis !() positions we can use the source_slice()
|
||||
# method. This does a much better job of capturing exactly the source code
|
||||
# that was provided. The tokenizer & lexer can be a little lossy, especially
|
||||
# with respect to whitespace.
|
||||
|
||||
def p_nocomma_tok(self, p):
|
||||
# see attachement function above for docstring
|
||||
# see attachment function above for docstring
|
||||
pass
|
||||
|
||||
def p_any_raw_tok(self, p):
|
||||
|
|
|
@ -25,7 +25,7 @@ class Parser(BaseParser):
|
|||
outputdir : str or None, optional
|
||||
The directory to place generated tables within.
|
||||
"""
|
||||
# Rule creation and modifiation *must* take place before super()
|
||||
# Rule creation and modification *must* take place before super()
|
||||
opt_rules = ['argument_comma_list', 'comma_argument_list']
|
||||
for rule in opt_rules:
|
||||
self._opt_rule(rule)
|
||||
|
|
|
@ -25,7 +25,7 @@ class Parser(BaseParser):
|
|||
outputdir : str or None, optional
|
||||
The directory to place generated tables within.
|
||||
"""
|
||||
# Rule creation and modifiation *must* take place before super()
|
||||
# Rule creation and modification *must* take place before super()
|
||||
tok_rules = ['await', 'async']
|
||||
for rule in tok_rules:
|
||||
self._tok_rule(rule)
|
||||
|
@ -113,7 +113,7 @@ class Parser(BaseParser):
|
|||
# to our LL(1) parser. Even though 'test' includes '*expr' in star_expr,
|
||||
# we explicitly match '*' here, too, to give it proper precedence.
|
||||
# Illegal combinations and orderings are blocked in ast.c:
|
||||
# multiple (test comp_for) arguements are blocked; keyword unpackings
|
||||
# multiple (test comp_for) arguments are blocked; keyword unpackings
|
||||
# that precede iterable unpackings are blocked; etc.
|
||||
def p_argument_test_or_star(self, p):
|
||||
"""argument : test_or_star_expr"""
|
||||
|
|
|
@ -200,7 +200,7 @@ def expanduser():
|
|||
def windows_expanduser(path):
|
||||
"""A Windows-specific expanduser() function for xonsh. This is needed
|
||||
since os.path.expanduser() does not check on Windows if the user actually
|
||||
exists. This restircts expanding the '~' if it is not followed by a
|
||||
exists. This restricts expanding the '~' if it is not followed by a
|
||||
separator. That is only '~/' and '~\' are expanded.
|
||||
"""
|
||||
if not path.startswith('~'):
|
||||
|
@ -361,7 +361,7 @@ def windows_bash_command():
|
|||
|
||||
if ON_WINDOWS:
|
||||
class OSEnvironCasePreserving(collections.MutableMapping):
|
||||
""" Case-preseving wrapper for os.environ on Windows.
|
||||
""" Case-preserving wrapper for os.environ on Windows.
|
||||
It uses nt.environ to get the correct cased keys on
|
||||
initialization. It also preserves the case of any variables
|
||||
add after initialization.
|
||||
|
@ -414,7 +414,7 @@ if ON_WINDOWS:
|
|||
|
||||
@lazyobject
|
||||
def os_environ():
|
||||
"""This dispatches to the correct, case-senstive version of os.envrion.
|
||||
"""This dispatches to the correct, case-sensitive version of os.environ.
|
||||
This is mainly a problem for Windows. See #2024 for more details.
|
||||
This can probably go away once support for Python v3.5 or v3.6 is
|
||||
dropped.
|
||||
|
@ -427,7 +427,7 @@ def os_environ():
|
|||
|
||||
@functools.lru_cache(1)
|
||||
def bash_command():
|
||||
"""Determines the command for Bash on the current plaform."""
|
||||
"""Determines the command for Bash on the current platform."""
|
||||
if ON_WINDOWS:
|
||||
bc = windows_bash_command()
|
||||
else:
|
||||
|
|
|
@ -310,7 +310,7 @@ class RepresentationPrinter(PrettyPrinter):
|
|||
printer for a python object.
|
||||
|
||||
This class stores processing data on `self` so you must *never* use
|
||||
this class in a threaded environment. Always lock it or reinstanciate
|
||||
this class in a threaded environment. Always lock it or reinstantiate
|
||||
it.
|
||||
|
||||
Instances also have a verbose flag callbacks can access to control their
|
||||
|
|
|
@ -220,8 +220,8 @@ class NonBlockingFDReader(QueueReader):
|
|||
|
||||
def populate_buffer(reader, fd, buffer, chunksize):
|
||||
"""Reads bytes from the file descriptor and copies them into a buffer.
|
||||
The reads happend in parallel, using pread(), and is thus only
|
||||
availabe on posix. If the read fails for any reason, the reader is
|
||||
The reads happened in parallel, using pread(), and is thus only
|
||||
available on posix. If the read fails for any reason, the reader is
|
||||
flagged as closed.
|
||||
"""
|
||||
offset = 0
|
||||
|
@ -280,7 +280,7 @@ def _expand_console_buffer(cols, max_offset, expandsize, orig_posize, fd):
|
|||
|
||||
def populate_console(reader, fd, buffer, chunksize, queue, expandsize=None):
|
||||
"""Reads bytes from the file descriptor and puts lines into the queue.
|
||||
The reads happend in parallel,
|
||||
The reads happened in parallel,
|
||||
using xonsh.winutils.read_console_output_character(),
|
||||
and is thus only available on windows. If the read fails for any reason,
|
||||
the reader is flagged as closed.
|
||||
|
@ -300,23 +300,23 @@ def populate_console(reader, fd, buffer, chunksize, queue, expandsize=None):
|
|||
# These chunked reads basically need to happen like this because,
|
||||
# a. The default buffer size is HUGE for the console (90k lines x 120 cols)
|
||||
# as so we can't just read in everything at the end and see what we
|
||||
# care about without a noticible performance hit.
|
||||
# care about without a noticeable performance hit.
|
||||
# b. Even with this huge size, it is still possible to write more lines than
|
||||
# this, so we should scroll along with the console.
|
||||
# Unfortnately, because we do not have control over the terminal emulator,
|
||||
# It is not possible to compute how far back we should set the begining
|
||||
# Unfortunately, because we do not have control over the terminal emulator,
|
||||
# It is not possible to compute how far back we should set the beginning
|
||||
# read position because we don't know how many characters have been popped
|
||||
# off the top of the buffer. If we did somehow know this number we could do
|
||||
# something like the following:
|
||||
#
|
||||
# new_offset = (y*cols) + x
|
||||
# if new_offset == max_offset:
|
||||
# new_offset -= scolled_offset
|
||||
# new_offset -= scrolled_offset
|
||||
# x = new_offset%cols
|
||||
# y = new_offset//cols
|
||||
# continue
|
||||
#
|
||||
# So this method is imperfect and only works as long as the sceen has
|
||||
# So this method is imperfect and only works as long as the screen has
|
||||
# room to expand to. Thus the trick here is to expand the screen size
|
||||
# when we get close enough to the end of the screen. There remain some
|
||||
# async issues related to not being able to set the cursor position.
|
||||
|
@ -488,7 +488,7 @@ def safe_flush(handle):
|
|||
|
||||
|
||||
def still_writable(fd):
|
||||
"""Determines whether a file descriptior is still writable by trying to
|
||||
"""Determines whether a file descriptor is still writable by trying to
|
||||
write an empty string and seeing if it fails.
|
||||
"""
|
||||
try:
|
||||
|
@ -664,7 +664,7 @@ class PopenThread(threading.Thread):
|
|||
|
||||
def _read_write(self, reader, writer, stdbuf):
|
||||
"""Reads a chunk of bytes from a buffer and write into memory or back
|
||||
down to the standard buffer, as approriate. Returns the number of
|
||||
down to the standard buffer, as appropriate. Returns the number of
|
||||
successful reads.
|
||||
"""
|
||||
if reader is None:
|
||||
|
@ -696,7 +696,7 @@ class PopenThread(threading.Thread):
|
|||
self._alt_mode_writer(chunk[:i], membuf, stdbuf)
|
||||
# switch modes
|
||||
# write the flag itself the current mode where alt mode is on
|
||||
# so that it is streamed to the termial ASAP.
|
||||
# so that it is streamed to the terminal ASAP.
|
||||
# this is needed for terminal emulators to find the correct
|
||||
# positions before and after alt mode.
|
||||
alt_mode = (flag in START_ALTERNATE_MODE)
|
||||
|
@ -950,7 +950,7 @@ class Handle(int):
|
|||
|
||||
class FileThreadDispatcher:
|
||||
"""Dispatches to different file handles depending on the
|
||||
current thread. Useful if you want file operation to go to differnt
|
||||
current thread. Useful if you want file operation to go to different
|
||||
places for different threads.
|
||||
"""
|
||||
|
||||
|
@ -960,7 +960,7 @@ class FileThreadDispatcher:
|
|||
----------
|
||||
default : file-like or None, optional
|
||||
The file handle to write to if a thread cannot be found in
|
||||
the registery. If None, a new in-memory instance.
|
||||
the registry. If None, a new in-memory instance.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
@ -1111,13 +1111,13 @@ class FileThreadDispatcher:
|
|||
|
||||
|
||||
# These should NOT be lazy since they *need* to get the true stdout from the
|
||||
# main thread. Also their creation time should be neglibible.
|
||||
# main thread. Also their creation time should be negligible.
|
||||
STDOUT_DISPATCHER = FileThreadDispatcher(default=sys.stdout)
|
||||
STDERR_DISPATCHER = FileThreadDispatcher(default=sys.stderr)
|
||||
|
||||
|
||||
def parse_proxy_return(r, stdout, stderr):
|
||||
"""Proxies may return a variety of outputs. This hanles them generally.
|
||||
"""Proxies may return a variety of outputs. This handles them generally.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
@ -1189,7 +1189,7 @@ PROXY_KWARG_NAMES = frozenset(['args', 'stdin', 'stdout', 'stderr', 'spec'])
|
|||
|
||||
|
||||
def partial_proxy(f):
|
||||
"""Dispatches the approriate proxy function based on the number of args."""
|
||||
"""Dispatches the appropriate proxy function based on the number of args."""
|
||||
numargs = 0
|
||||
for name, param in inspect.signature(f).parameters.items():
|
||||
if param.kind == param.POSITIONAL_ONLY or \
|
||||
|
@ -1236,7 +1236,8 @@ class ProcProxyThread(threading.Thread):
|
|||
set to `None`, then `sys.stderr` is used.
|
||||
universal_newlines : bool, optional
|
||||
Whether or not to use universal newlines.
|
||||
env : Mapping, optiona Environment mapping.
|
||||
env : Mapping, optional
|
||||
Environment mapping.
|
||||
"""
|
||||
self.orig_f = f
|
||||
self.f = partial_proxy(f)
|
||||
|
@ -1408,7 +1409,7 @@ class ProcProxyThread(threading.Thread):
|
|||
|
||||
def _signal_int(self, signum, frame):
|
||||
"""Signal handler for SIGINT - Ctrl+C may have been pressed."""
|
||||
# check if we have already be interrupted to prevent infintie recurrsion
|
||||
# check if we have already be interrupted to prevent infinite recursion
|
||||
if self._interrupted:
|
||||
return
|
||||
self._interrupted = True
|
||||
|
@ -1605,7 +1606,7 @@ class ProcProxy(object):
|
|||
|
||||
def wait(self, timeout=None):
|
||||
"""Runs the function and returns the result. Timeout argument only
|
||||
present for API compatability.
|
||||
present for API compatibility.
|
||||
"""
|
||||
if self.f is None:
|
||||
return 0
|
||||
|
@ -1722,7 +1723,7 @@ class CommandPipeline:
|
|||
Parameters
|
||||
----------
|
||||
specs : list of SubprocSpec
|
||||
Process sepcifications
|
||||
Process specifications
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
@ -1798,7 +1799,7 @@ class CommandPipeline:
|
|||
"""Iterates through the last stdout, and returns the lines
|
||||
exactly as found.
|
||||
"""
|
||||
# get approriate handles
|
||||
# get appropriate handles
|
||||
spec = self.spec
|
||||
proc = self.proc
|
||||
timeout = builtins.__xonsh_env__.get('XONSH_PROC_FREQUENCY')
|
||||
|
@ -2094,7 +2095,7 @@ class CommandPipeline:
|
|||
self._safe_close(s.captured_stderr)
|
||||
|
||||
def _set_input(self):
|
||||
"""Sets the input vaiable."""
|
||||
"""Sets the input variable."""
|
||||
stdin = self.proc.stdin
|
||||
if stdin is None or isinstance(stdin, int) or stdin.closed or \
|
||||
not stdin.seekable() or not safe_readable(stdin):
|
||||
|
@ -2105,7 +2106,7 @@ class CommandPipeline:
|
|||
self.input = self._decode_uninew(input)
|
||||
|
||||
def _check_signal(self):
|
||||
"""Checks if a signal was recieved and issues a message."""
|
||||
"""Checks if a signal was received and issues a message."""
|
||||
proc_signal = getattr(self.proc, 'signal', None)
|
||||
if proc_signal is None:
|
||||
return
|
||||
|
@ -2125,7 +2126,7 @@ class CommandPipeline:
|
|||
hist.last_cmd_rtn = self.proc.returncode
|
||||
|
||||
def _raise_subproc_error(self):
|
||||
"""Raises a subprocess error, if we are suppossed to."""
|
||||
"""Raises a subprocess error, if we are supposed to."""
|
||||
spec = self.spec
|
||||
rtn = self.returncode
|
||||
if (not spec.is_proxy and
|
||||
|
@ -2296,7 +2297,7 @@ def pause_call_resume(p, f, *args, **kwargs):
|
|||
class PrevProcCloser(threading.Thread):
|
||||
"""Previous process closer thread for pipelines whose last command
|
||||
is itself unthreadable. This makes sure that the pipeline is
|
||||
driven foreward and does not deadlock.
|
||||
driven forward and does not deadlock.
|
||||
"""
|
||||
|
||||
def __init__(self, pipeline):
|
||||
|
@ -2312,7 +2313,7 @@ class PrevProcCloser(threading.Thread):
|
|||
self.start()
|
||||
|
||||
def run(self):
|
||||
"""Runs the closing algorithim."""
|
||||
"""Runs the closing algorithm."""
|
||||
pipeline = self.pipeline
|
||||
check_prev_done = len(pipeline.procs) == 1
|
||||
if check_prev_done:
|
||||
|
|
|
@ -71,7 +71,7 @@ class PromptFormatter:
|
|||
val = self._get_field_value(field)
|
||||
return _format_value(val, spec, conv)
|
||||
else:
|
||||
# color or unkown field, return as is
|
||||
# color or unknown field, return as is
|
||||
return '{' + field + '}'
|
||||
|
||||
def _get_field_value(self, field):
|
||||
|
@ -158,7 +158,7 @@ def multiline_prompt(curr=''):
|
|||
headlen = len(head)
|
||||
# tail is the trailing whitespace
|
||||
tail = line if headlen == 0 else line.rsplit(head[-1], 1)[1]
|
||||
# now to constuct the actual string
|
||||
# now to construct the actual string
|
||||
dots = builtins.__xonsh_env__.get('MULTILINE_PROMPT')
|
||||
dots = dots() if callable(dots) else dots
|
||||
if dots is None or len(dots) == 0:
|
||||
|
|
|
@ -20,7 +20,7 @@ def env_name(pre_chars='(', post_chars=')'):
|
|||
|
||||
|
||||
def vte_new_tab_cwd():
|
||||
"""This prints an escape squence that tells VTE terminals the hostname
|
||||
"""This prints an escape sequence that tells VTE terminals the hostname
|
||||
and pwd. This should not be needed in most cases, but sometimes is for
|
||||
certain Linux terminals that do not read the PWD from the environment
|
||||
on startup. Note that this does not return a string, it simply prints
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Prompt formatter for simple version control branchs"""
|
||||
"""Prompt formatter for simple version control branches"""
|
||||
# pylint:disable=no-member, invalid-name
|
||||
|
||||
import os
|
||||
|
@ -234,7 +234,7 @@ def branch_color():
|
|||
|
||||
def branch_bg_color():
|
||||
"""Return red if the current branch is dirty, yellow if the dirtiness can
|
||||
not be determined, and green if it clean. These are bacground colors.
|
||||
not be determined, and green if it clean. These are background colors.
|
||||
"""
|
||||
dwd = dirty_working_directory()
|
||||
if dwd is None:
|
||||
|
|
|
@ -7,7 +7,7 @@ import prompt_toolkit.history
|
|||
|
||||
|
||||
class PromptToolkitHistory(prompt_toolkit.history.History):
|
||||
"""History class that implements the promt-toolkit history interface
|
||||
"""History class that implements the prompt-toolkit history interface
|
||||
with the xonsh backend.
|
||||
"""
|
||||
|
||||
|
|
|
@ -306,8 +306,8 @@ class PromptToolkitShell(BaseShell):
|
|||
# needs to be performed by the subprocess itself. This fix is important
|
||||
# when subprocesses don't properly restore the terminal attributes,
|
||||
# like Python in interactive mode. Also note that the sequences "\033M"
|
||||
# and "\033E" seem to work too, but these are techinally VT100 codes.
|
||||
# I used the more primitive ANSI sequence to maximize compatability.
|
||||
# and "\033E" seem to work too, but these are technically VT100 codes.
|
||||
# I used the more primitive ANSI sequence to maximize compatibility.
|
||||
# -scopatz 2017-01-28
|
||||
# if not ON_POSIX:
|
||||
# return
|
||||
|
|
|
@ -242,7 +242,7 @@ def color_by_name(name, fg=None, bg=None):
|
|||
fg = norm_name(name)
|
||||
else:
|
||||
bg = norm_name(name)
|
||||
# assmble token
|
||||
# assemble token
|
||||
if fg is None and bg is None:
|
||||
tokname = 'NO_COLOR'
|
||||
elif fg is None:
|
||||
|
@ -360,7 +360,7 @@ def _partial_color_tokenize_main(template, styles):
|
|||
|
||||
|
||||
class CompoundColorMap(MutableMapping):
|
||||
"""Looks up color tokes by name, potentailly generating the value
|
||||
"""Looks up color tokes by name, potentially generating the value
|
||||
from the lookup.
|
||||
"""
|
||||
|
||||
|
@ -410,7 +410,7 @@ class XonshStyle(Style):
|
|||
style_name : str, optional
|
||||
The style name to initialize with.
|
||||
"""
|
||||
self.trap = {} # for traping custom colors set by user
|
||||
self.trap = {} # for trapping custom colors set by user
|
||||
self._smap = {}
|
||||
self._style_name = ''
|
||||
self.style_name = style_name
|
||||
|
@ -453,7 +453,7 @@ class XonshStyle(Style):
|
|||
def enhance_colors_for_cmd_exe(self):
|
||||
""" Enhance colors when using cmd.exe on windows.
|
||||
When using the default style all blue and dark red colors
|
||||
are changed to CYAN and intence red.
|
||||
are changed to CYAN and intense red.
|
||||
"""
|
||||
env = builtins.__xonsh_env__
|
||||
# Ensure we are not using ConEmu
|
||||
|
|
|
@ -134,7 +134,7 @@ def setup_readline():
|
|||
except Exception:
|
||||
# this seems to fail with libedit
|
||||
print_exception('xonsh: could not load readline default init file.')
|
||||
# properly reset intput typed before the first prompt
|
||||
# properly reset input typed before the first prompt
|
||||
readline.set_startup_hook(carriage_return)
|
||||
|
||||
|
||||
|
@ -184,7 +184,7 @@ def fix_readline_state_after_ctrl_c():
|
|||
|
||||
|
||||
def rl_completion_suppress_append(val=1):
|
||||
"""Sets the rl_completion_suppress_append varaiable, if possible.
|
||||
"""Sets the rl_completion_suppress_append variable, if possible.
|
||||
A value of 1 (default) means to suppress, a value of 0 means to enable.
|
||||
"""
|
||||
if RL_COMPLETION_SUPPRESS_APPEND is None:
|
||||
|
@ -193,7 +193,7 @@ def rl_completion_suppress_append(val=1):
|
|||
|
||||
|
||||
def rl_completion_query_items(val=None):
|
||||
"""Sets the rl_completion_query_items varaiable, if possible.
|
||||
"""Sets the rl_completion_query_items variable, if possible.
|
||||
A None value will set this to $COMPLETION_QUERY_LIMIT, otherwise any integer
|
||||
is accepted.
|
||||
"""
|
||||
|
@ -506,7 +506,7 @@ class ReadlineShell(BaseShell, cmd.Cmd):
|
|||
return p
|
||||
|
||||
def format_color(self, string, hide=False, force_string=False, **kwargs):
|
||||
"""Readline implementation of color formatting. This usess ANSI color
|
||||
"""Readline implementation of color formatting. This uses ANSI color
|
||||
codes.
|
||||
"""
|
||||
hide = hide if self._force_hide is None else self._force_hide
|
||||
|
|
|
@ -39,7 +39,7 @@ class Replayer(object):
|
|||
Parameters
|
||||
----------
|
||||
merge_env : tuple of str or Mappings, optional
|
||||
Describes how to merge the environments, in order of increasing precednce.
|
||||
Describes how to merge the environments, in order of increasing precedence.
|
||||
Available strings are 'replay' and 'native'. The 'replay' env comes from the
|
||||
history file that we are replaying. The 'native' env comes from what this
|
||||
instance of xonsh was started up with. Instead of a string, a dict or other
|
||||
|
|
|
@ -150,7 +150,7 @@ class Shell(object):
|
|||
shell_type))
|
||||
self.shell = shell_class(execer=self.execer,
|
||||
ctx=self.ctx, **kwargs)
|
||||
# allows history garbage colector to start running
|
||||
# allows history garbage collector to start running
|
||||
if hist.gc is not None:
|
||||
hist.gc.wait_for_shell = False
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ def color_by_name(name, fg=None, bg=None):
|
|||
fg = norm_name(name)
|
||||
else:
|
||||
bg = norm_name(name)
|
||||
# assmble token
|
||||
# assemble token
|
||||
if fg is None and bg is None:
|
||||
tokname = 'NO_COLOR'
|
||||
elif fg is None:
|
||||
|
|
|
@ -211,7 +211,7 @@ def timeit_alias(args, stdin=None):
|
|||
worst = max(worst, worst_tuning)
|
||||
# Check best timing is greater than zero to avoid a
|
||||
# ZeroDivisionError.
|
||||
# In cases where the slowest timing is lesser than 10 micoseconds
|
||||
# In cases where the slowest timing is lesser than 10 microseconds
|
||||
# we assume that it does not really matter if the fastest
|
||||
# timing is 4 times faster than the slowest timing or not.
|
||||
if worst > 4 * best and best > 0 and worst > 1e-5:
|
||||
|
|
|
@ -801,7 +801,7 @@ def _tokenize(readline, encoding):
|
|||
|
||||
def tokenize(readline):
|
||||
"""
|
||||
The tokenize() generator requires one argment, readline, which
|
||||
The tokenize() generator requires one argument, readline, which
|
||||
must be a callable object which provides the same interface as the
|
||||
readline() method of built-in file objects. Each call to the function
|
||||
should return one line of input as bytes. Alternately, readline
|
||||
|
|
|
@ -284,7 +284,7 @@ def find_next_break(line, mincol=0, lexer=None):
|
|||
|
||||
def subproc_toks(line, mincol=-1, maxcol=None, lexer=None, returnline=False,
|
||||
greedy=False):
|
||||
"""Excapsulates tokens in a source code line in a uncaptured
|
||||
"""Encapsulates tokens in a source code line in a uncaptured
|
||||
subprocess ![] starting at a minimum column. If there are no tokens
|
||||
(ie in a comment line) this returns None. If greedy is True, it will encapsulate
|
||||
normal parentheses. Greedy is False by default.
|
||||
|
@ -418,7 +418,7 @@ def _have_open_triple_quotes(s):
|
|||
|
||||
|
||||
def get_line_continuation():
|
||||
""" The line contiuation characters used in subproc mode. In interactive
|
||||
""" The line continuation characters used in subproc mode. In interactive
|
||||
mode on Windows the backslash must be preceded by a space. This is because
|
||||
paths on Windows may end in a backslash.
|
||||
"""
|
||||
|
@ -504,7 +504,7 @@ def subexpr_from_unbalanced(expr, ltok, rtok):
|
|||
|
||||
|
||||
def subexpr_before_unbalanced(expr, ltok, rtok):
|
||||
"""Obtains the expression prior to last unblanced left token."""
|
||||
"""Obtains the expression prior to last unbalanced left token."""
|
||||
subexpr, _, post = expr.rpartition(ltok)
|
||||
nrtoks_in_post = post.count(rtok)
|
||||
while nrtoks_in_post != 0:
|
||||
|
@ -875,7 +875,7 @@ def suggestion_sort_helper(x, y):
|
|||
|
||||
def escape_windows_cmd_string(s):
|
||||
"""Returns a string that is usable by the Windows cmd.exe.
|
||||
The escaping is based on details here and emperical testing:
|
||||
The escaping is based on details here and empirical testing:
|
||||
http://www.robvanderwoude.com/escapechars.php
|
||||
"""
|
||||
for c in '()%!^<>&|"':
|
||||
|
@ -1427,7 +1427,7 @@ def is_history_backend(x):
|
|||
|
||||
def is_dynamic_cwd_width(x):
|
||||
""" Determine if the input is a valid input for the DYNAMIC_CWD_WIDTH
|
||||
environement variable.
|
||||
environment variable.
|
||||
"""
|
||||
return (isinstance(x, tuple) and
|
||||
len(x) == 2 and
|
||||
|
@ -1463,7 +1463,7 @@ RE_HISTORY_TUPLE = LazyObject(
|
|||
|
||||
|
||||
def to_history_tuple(x):
|
||||
"""Converts to a canonincal history tuple."""
|
||||
"""Converts to a canonical history tuple."""
|
||||
if not isinstance(x, (cabc.Sequence, float, int)):
|
||||
raise ValueError('history size must be given as a sequence or number')
|
||||
if isinstance(x, str):
|
||||
|
@ -1612,7 +1612,7 @@ def format_std_prepost(template, env=None):
|
|||
except Exception:
|
||||
print_exception()
|
||||
# \001\002 is there to fool pygments into not returning an empty string
|
||||
# for potentially empty input. This happend when the template is just a
|
||||
# for potentially empty input. This happens when the template is just a
|
||||
# color code with no visible text.
|
||||
invis = '\001\002'
|
||||
s = shell.format_color(invis + s + invis, force_string=True)
|
||||
|
@ -1725,7 +1725,7 @@ def check_for_partial_string(x):
|
|||
return (string_indices[-2], string_indices[-1], starting_quote[-1])
|
||||
|
||||
|
||||
# regular expressions for matching enviroment variables
|
||||
# regular expressions for matching environment variables
|
||||
# i.e $FOO, ${'FOO'}
|
||||
@lazyobject
|
||||
def POSIX_ENVVAR_REGEX():
|
||||
|
@ -1771,7 +1771,7 @@ def backup_file(fname):
|
|||
|
||||
|
||||
def normabspath(p):
|
||||
"""Retuns as normalized absolute path, namely, normcase(abspath(p))"""
|
||||
"""Returns as normalized absolute path, namely, normcase(abspath(p))"""
|
||||
return os.path.normcase(os.path.abspath(p))
|
||||
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class TracerType(object):
|
|||
# we have to use a function to set usecolor because of the way that
|
||||
# lazyasd works. Namely, it cannot dispatch setattr to the target
|
||||
# object without being unable to access its own __dict__. This makes
|
||||
# setting an atter look like getting a function.
|
||||
# setting an attr look like getting a function.
|
||||
self.usecolor = usecolor
|
||||
|
||||
def start(self, filename):
|
||||
|
|
|
@ -28,7 +28,7 @@ from ctypes.wintypes import (HANDLE, BOOL, DWORD, HWND, HINSTANCE, HKEY,
|
|||
LPDWORD, SHORT, LPCWSTR, WORD, SMALL_RECT, LPCSTR)
|
||||
|
||||
from xonsh.lazyasd import lazyobject
|
||||
from xonsh import lazyimps # we aren't amagamated in this module.
|
||||
from xonsh import lazyimps # we aren't amalgamated in this module.
|
||||
from xonsh import platform
|
||||
|
||||
|
||||
|
@ -246,7 +246,7 @@ def set_console_mode(mode, fd=1):
|
|||
|
||||
def enable_virtual_terminal_processing():
|
||||
"""Enables virtual terminal processing on Windows.
|
||||
This inlcudes ANSI escape sequence interpretation.
|
||||
This includes ANSI escape sequence interpretation.
|
||||
See http://stackoverflow.com/a/36760881/2312428
|
||||
"""
|
||||
SetConsoleMode(GetStdHandle(-11), 7)
|
||||
|
@ -305,7 +305,7 @@ def ReadConsoleOutputCharacterW():
|
|||
|
||||
def read_console_output_character(x=0, y=0, fd=1, buf=None, bufsize=1024,
|
||||
raw=False):
|
||||
"""Reads chracters from the console buffer.
|
||||
"""Reads characters from the console buffer.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
@ -320,7 +320,7 @@ def read_console_output_character(x=0, y=0, fd=1, buf=None, bufsize=1024,
|
|||
An existing buffer to (re-)use.
|
||||
bufsize : int, optional
|
||||
The maximum read size.
|
||||
raw : bool, opional
|
||||
raw : bool, optional
|
||||
Whether to read in and return as bytes (True) or as a
|
||||
unicode string (False, default).
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class Question(Node):
|
|||
Mapping from user-input responses to nodes.
|
||||
converter : callable, optional
|
||||
Converts the string the user typed into another object
|
||||
that serves as a key to the reponses dict.
|
||||
that serves as a key to the responses dict.
|
||||
path : str or sequence of str, optional
|
||||
A path within the storage object.
|
||||
"""
|
||||
|
@ -99,7 +99,7 @@ class Input(Node):
|
|||
default False.
|
||||
retry : bool, optional
|
||||
In the event that the conversion operation fails, should
|
||||
users be re-prompted until they provide valid input. Deafult False.
|
||||
users be re-prompted until they provide valid input. Default False.
|
||||
path : str or sequence of str, optional
|
||||
A path within the storage object.
|
||||
"""
|
||||
|
@ -114,7 +114,7 @@ class Input(Node):
|
|||
class While(Node):
|
||||
"""Computes a body while a condition function evaluates to true.
|
||||
The condition function has the form cond(visitor=None, node=None) and
|
||||
should return an object that is convertable to a bool. The beg attribute
|
||||
should return an object that is convertible to a bool. The beg attribute
|
||||
specifies the number to start the loop iteration at.
|
||||
"""
|
||||
|
||||
|
@ -128,7 +128,7 @@ class While(Node):
|
|||
Function that determines if the next loop iteration should
|
||||
be executed. The condition function has the form
|
||||
cond(visitor=None, node=None) and should return an object that
|
||||
is convertable to a bool.
|
||||
is convertible to a bool.
|
||||
body : sequence of nodes
|
||||
A list of node to execute on each iteration.
|
||||
idxname : str, optional
|
||||
|
@ -212,7 +212,7 @@ class StoreNonEmpty(Input):
|
|||
|
||||
|
||||
class StateFile(Input):
|
||||
"""Node for repesenting the state as a JSON file under a default or user
|
||||
"""Node for representing the state as a JSON file under a default or user
|
||||
given file name. This node type is likely not useful on its own.
|
||||
"""
|
||||
|
||||
|
|
|
@ -530,7 +530,7 @@ def STRIP_COLOR_RE():
|
|||
|
||||
|
||||
def _align_string(string, align='<', fill=' ', width=80):
|
||||
""" Align and pad a color formattet string """
|
||||
""" Align and pad a color formatted string """
|
||||
linelen = len(STRIP_COLOR_RE.sub('', string))
|
||||
padlen = max(width-linelen, 0)
|
||||
if align == '^':
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
"""Additional core utilites that are implemented in xonsh. The current list
|
||||
"""Additional core utilities that are implemented in xonsh. The current list
|
||||
includes:
|
||||
|
||||
* cat
|
||||
|
|
|
@ -5,7 +5,7 @@ __all__ = 'DSubmitter', 'dsubmit'
|
|||
|
||||
|
||||
def dworker(args, stdin=None):
|
||||
"""Programatic access to the dworker utility, to allow launching
|
||||
"""Programmatic access to the dworker utility, to allow launching
|
||||
workers that also have access to xonsh builtins.
|
||||
"""
|
||||
from distributed.cli import dworker
|
||||
|
|
|
@ -32,7 +32,7 @@ def _cwd_release_wrapper(func):
|
|||
""" Decorator for Windows to the wrap the prompt function and release
|
||||
the process lock on the current directory while the prompt is
|
||||
displayed. This works by temporarily setting
|
||||
the workdir to the users home direcotry.
|
||||
the workdir to the users home directory.
|
||||
"""
|
||||
env = builtins.__xonsh_env__
|
||||
if env.get('UPDATE_PROMPT_ON_KEYPRESS'):
|
||||
|
|
|
@ -44,7 +44,7 @@ def interactive_pyplot(module=None, **kwargs):
|
|||
"""This is a monkey patched version of matplotlib.pyplot.show()
|
||||
for xonsh's interactive mode. First it tries non-blocking mode
|
||||
(block=False). If for some reason this fails, it will run show
|
||||
in normal bloking mode (block=True).
|
||||
in normal blocking mode (block=True).
|
||||
"""
|
||||
kwargs.update(block=False)
|
||||
rtn = plt_show(*args, **kwargs)
|
||||
|
|
|
@ -93,7 +93,7 @@ def figure_to_tight_array(fig, width, height, minimal=True):
|
|||
# leave only one line for top and bottom
|
||||
fig.subplots_adjust(bottom=1/height, top=1-1/height, left=0, right=1)
|
||||
|
||||
# redeuce font size in order to reduce text impact on the image
|
||||
# reduce font size in order to reduce text impact on the image
|
||||
font_size = matplotlib.rcParams['font.size']
|
||||
matplotlib.rcParams.update({'font.size': 0})
|
||||
else:
|
||||
|
|
|
@ -106,7 +106,7 @@ class VoxHandler:
|
|||
print('Activated "%s".\n' % args.name)
|
||||
|
||||
def cmd_deactivate(self, args, stdin=None):
|
||||
"""Deactive the active virtual environment."""
|
||||
"""Deactivate the active virtual environment."""
|
||||
|
||||
if self.vox.active() is None:
|
||||
print('No environment currently active. Activate one with "vox activate".\n', file=sys.stderr)
|
||||
|
|
Loading…
Add table
Reference in a new issue