mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
commit
2e42a42f41
5 changed files with 68 additions and 15 deletions
|
@ -28,6 +28,12 @@ jobs:
|
|||
updateConda: false
|
||||
condition: eq(variables['python.version'], '3.5')
|
||||
displayName: 'Conda Environment (conda-forge/label/cf201901)'
|
||||
- task: CondaEnvironment@1
|
||||
inputs:
|
||||
packageSpecs: 'python=$(python.version) pygments prompt_toolkit ply pytest pytest-timeout numpy psutil matplotlib flake8 coverage pyflakes pytest-cov pytest-flake8 codecov'
|
||||
installOptions: '-c conda-forge/label/cf201901'
|
||||
updateConda: false
|
||||
condition: eq(variables['python.version'], '3.5')
|
||||
- task: CondaEnvironment@1
|
||||
inputs:
|
||||
packageSpecs: 'python=$(python.version) pygments prompt_toolkit ply pytest pytest-timeout numpy psutil matplotlib flake8 coverage pyflakes pytest-cov pytest-flake8 codecov'
|
||||
|
|
26
news/hsah.rst
Normal file
26
news/hsah.rst
Normal file
|
@ -0,0 +1,26 @@
|
|||
**Added:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Changed:**
|
||||
|
||||
* Some minor ``history show`` efficiency improvements.
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* Fixed issue with recursive aliases not being passes all keyword arguments
|
||||
that are part of the callable alias spec. This allows commands like
|
||||
``aliases['hsa'] = "history show all"; hsa | head`` to no longer fail
|
||||
with strange errors.
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -13,7 +13,7 @@ from xonsh.environ import Env
|
|||
from tools import skip_if_on_windows
|
||||
|
||||
|
||||
def cd(args, stdin=None):
|
||||
def cd(args, stdin=None, **kwargs):
|
||||
return args
|
||||
|
||||
|
||||
|
@ -61,3 +61,18 @@ def test_eval_recursive_callable_partial(xonsh_execer, xonsh_builtins):
|
|||
ales = make_aliases()
|
||||
xonsh_builtins.__xonsh__.env = Env(HOME=os.path.expanduser("~"))
|
||||
assert ales.get("indirect_cd")(["arg2", "arg3"]) == ["..", "arg2", "arg3"]
|
||||
|
||||
|
||||
def _return_to_sender(args, **kwargs):
|
||||
return args, kwargs
|
||||
|
||||
|
||||
def test_recursive_callable_partial_(xonsh_execer, xonsh_builtins):
|
||||
ales = Aliases({"rtn": _return_to_sender, "rtn-recurse": ["rtn", "arg1"]})
|
||||
alias = ales.get("rtn-recurse")
|
||||
assert callable(alias)
|
||||
args, obs = alias(["arg2"], stdin="a", stdout="b", stderr="c", spec="d", stack="e")
|
||||
assert args == ["arg1", "arg2"]
|
||||
assert len(obs) == 5
|
||||
exp = {"stdin": "a", "stdout": "b", "stderr": "c", "spec": "d", "stack": "e"}
|
||||
assert obs == exp
|
||||
|
|
|
@ -84,9 +84,18 @@ class Aliases(cabc.MutableMapping):
|
|||
if callable(value):
|
||||
if acc_args: # Partial application
|
||||
|
||||
def _alias(args, stdin=None):
|
||||
def _alias(
|
||||
args, stdin=None, stdout=None, stderr=None, spec=None, stack=None
|
||||
):
|
||||
args = list(acc_args) + args
|
||||
return value(args, stdin=stdin)
|
||||
return value(
|
||||
args,
|
||||
stdin=stdin,
|
||||
stdout=stdout,
|
||||
stderr=stderr,
|
||||
spec=spec,
|
||||
stack=stack,
|
||||
)
|
||||
|
||||
return _alias
|
||||
else:
|
||||
|
|
|
@ -184,37 +184,32 @@ def _xh_show_history(hist, ns, stdout=None, stderr=None):
|
|||
end_time=ns.end_time,
|
||||
datetime_format=ns.datetime_format,
|
||||
)
|
||||
except ValueError as err:
|
||||
except Exception as err:
|
||||
print("history: error: {}".format(err), file=stderr)
|
||||
return
|
||||
if ns.reverse:
|
||||
commands = reversed(list(commands))
|
||||
end = "\0" if ns.null_byte else "\n"
|
||||
if ns.numerate and ns.timestamp:
|
||||
for c in commands:
|
||||
dt = datetime.datetime.fromtimestamp(c["ts"])
|
||||
print(
|
||||
"{}:({}) {}".format(c["ind"], xt.format_datetime(dt), c["inp"]),
|
||||
file=stdout,
|
||||
end="\n" if not ns.null_byte else "\0",
|
||||
end=end,
|
||||
)
|
||||
elif ns.numerate:
|
||||
for c in commands:
|
||||
print(
|
||||
"{}: {}".format(c["ind"], c["inp"]),
|
||||
file=stdout,
|
||||
end="\n" if not ns.null_byte else "\0",
|
||||
)
|
||||
print("{}: {}".format(c["ind"], c["inp"]), file=stdout, end=end)
|
||||
elif ns.timestamp:
|
||||
for c in commands:
|
||||
dt = datetime.datetime.fromtimestamp(c["ts"])
|
||||
print(
|
||||
"({}) {}".format(xt.format_datetime(dt), c["inp"]),
|
||||
file=stdout,
|
||||
end="\n" if not ns.null_byte else "\0",
|
||||
"({}) {}".format(xt.format_datetime(dt), c["inp"]), file=stdout, end=end
|
||||
)
|
||||
else:
|
||||
for c in commands:
|
||||
print(c["inp"], file=stdout, end="\n" if not ns.null_byte else "\0")
|
||||
print(c["inp"], file=stdout, end=end)
|
||||
|
||||
|
||||
@xla.lazyobject
|
||||
|
@ -382,7 +377,9 @@ def _xh_parse_args(args):
|
|||
return ns
|
||||
|
||||
|
||||
def history_main(args=None, stdin=None, stdout=None, stderr=None):
|
||||
def history_main(
|
||||
args=None, stdin=None, stdout=None, stderr=None, spec=None, stack=None
|
||||
):
|
||||
"""This is the history command entry point."""
|
||||
hist = builtins.__xonsh__.history
|
||||
ns = _xh_parse_args(args)
|
||||
|
|
Loading…
Add table
Reference in a new issue