Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@lazyobject
def PYTHON_VERSION_INFO_BYTES():
"""The python version info tuple in a canonical bytes form."""
return ".".join(map(str, sys.version_info)).encode()
@lazyobject
def _deferred_type_pprinters():
dtp = {}
for_type_by_name('collections', 'defaultdict', _defaultdict_pprint, dtp=dtp)
for_type_by_name('collections', 'OrderedDict', _ordereddict_pprint, dtp=dtp)
for_type_by_name('collections', 'deque', _deque_pprint, dtp=dtp)
for_type_by_name('collections', 'Counter', _counter_pprint, dtp=dtp)
return dtp
@lazyobject
def _REDIR_REGEX():
name = r"(o(?:ut)?|e(?:rr)?|a(?:ll)?|&?\d?)"
return re.compile("{r}(>?>|<){r}$".format(r=name))
@lazyobject
def HG_PREDICTOR_PARSER():
p = argparse.ArgumentParser("hg", add_help=False)
p.add_argument("command")
p.add_argument(
"-i", "--interactive", action="store_true", default=False, dest="interactive"
)
return p
@lazyobject
def BASH_COMPLETIONS_DEFAULT():
"""A possibly empty tuple with default paths to Bash completions known for
the current platform.
"""
if ON_LINUX or ON_CYGWIN or ON_MSYS:
bcd = ("/usr/share/bash-completion/bash_completion",)
elif ON_DARWIN:
bcd = (
"/usr/local/share/bash-completion/bash_completion", # v2.x
"/usr/local/etc/bash_completion",
) # v1.x
elif ON_WINDOWS and git_for_windows_path():
bcd = (
os.path.join(
git_for_windows_path(), "usr\\share\\bash-completion\\bash_completion"
),
@lazyobject
def clocku():
if _HAVE_RESOURCE:
def clocku():
"""clocku() -> floating point number
Return the *USER* CPU time in seconds since the start of the
process."""
return resource.getrusage(resource.RUSAGE_SELF)[0]
else:
clocku = time.perf_counter
return clocku
@lazyobject
def token_map():
"""Mapping from ``tokenize`` tokens (or token types) to PLY token types. If
a simple one-to-one mapping from ``tokenize`` to PLY exists, the lexer will
look it up here and generate a single PLY token of the given type.
Otherwise, it will fall back to handling that token using one of the
handlers in``special_handlers``.
"""
tm = {}
# operators
_op_map = {
# punctuation
",": "COMMA",
".": "PERIOD",
";": "SEMI",
":": "COLON",
"...": "ELLIPSIS",
@lazyobject
def parser():
p = argparse.ArgumentParser(description="xonsh", add_help=False)
p.add_argument(
"-h",
"--help",
dest="help",
action="store_true",
default=False,
help="show help and exit",
)
p.add_argument(
"-V",
"--version",
dest="version",
action="store_true",
default=False,
@lazyobject
def FS_EXEC_ALIAS_RE():
return re.compile(r";|`|\$\(")
@lazyobject
def FS_EXEC_ALIAS_RE():
return re.compile(r";|`|\$\(")