Library of decorator aliases (daliases) for the xonsh shell.
If you like the idea click ⭐ on the repo and tweet.
Installation
To install use pip:
xpip install xontrib-dalias
# or
xpip install 'xontrib-dalias[dict,yaml]' # With extra decorators.
Load:
xontrib load dalias
Usage
Transform output to object
Decorators:
XSH.aliases['@split'] = _mod({"output_format": _split_output}, "Alias decorator. Output format: list of parts.")
XSH.aliases['@split-lines'] = _mod({"output_format": _split_lines_output}, "Alias decorator. Output format: list of splitted lines.")
XSH.aliases['@split-lexer'] = _mod({"output_format": _lexer_split_output}, "Alias decorator. Output format: list of parts by xonsh lexer (same as @$()).")
XSH.aliases['@split-lexer-lines'] = _mod({"output_format": _lexer_split_lines_output}, "Alias decorator. Output format: list of splitted lines by xonsh lexer (same as @$()).")
- Default:
@lines- return list of lines.@json- json to Pythondict.@jsonl- json lines to Pythonlistwithdictobjects.@path- string topathlib.Path.@split- split output by whitespaces.@split-lines- split output lines by whitespaces.@split-lexer- split output into parts using xonsh lexer. It's the same as builtin@$()operator.@split-lexer-lines- split output lines into parts using xonsh lexer. It's the same as builtin@$()operator.
- Extra (
xpip install 'xontrib-dalias[dict,yaml]'):@dict- dict-like object (json, JavaScript object, Python dict) to Pythondict.@dictl- dict-like objects (json, JavaScript object, Python dict) to Pythonlistwithdictobjects.@yaml- YAML to Pythondict.
Examples
$(@lines ls /)
# ['/bin', '/etc', '/home']
$(@json echo '{"a":1}') # Try with `curl` ;)
# dict({"a":1})
$(@jsonl echo '{"a":1}\n{"b":2}')
# [{'a': 1}, {'b': 2}]
docker inspect @($(@json docker ps --format json)['ID'])
# Container info
$(@path which -s xonsh)
# Path('/path/to/xonsh')
$(@path which -s xonsh).parent
# Path('/path/to')
$(@path echo '/tmp1\n/tmp2')
# [Path('/tmp1'), Path('/tmp2')]
$(@path echo ' ') # Safe
# None
$(@path echo ' \n\n/tmp1') # Safe
# [Path('/tmp1')]
aliases['ydig'] = '@yaml dig +yaml' # Update `dig` via `brew install bind` to have `+yaml`.
y = $(ydig google.com)
y[0]['type']
# 'MESSAGE'
Piping into decorated alias to get object:
$(echo '{"a":1}' | @json cat)
# dict({"a":1})
aliases['@j'] = '@json cat'
$(echo '{"a":1}' | @j)
# dict({"a":1})
Error handling
Default decorators:
@err- set$RAISE_SUBPROC_ERROR=Truefor the command.@noerr- set$RAISE_SUBPROC_ERROR=Falsefor the command.
Examples:
$RAISE_SUBPROC_ERROR = True # General environment.
if ![@noerr ls nononofile]: # Do not raise exception in case of error.
echo file
Credits
This package was created with xontrib template.
Metadata
Release files for xontrib-dalias 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xontrib_dalias-0.0.10.tar.gz | 6.1 kB | Without provenance | Details for xontrib_dalias-0.0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xontrib_dalias-0.0.10-py3-none-any.whl | Python 3 | none | any | Details for xontrib_dalias-0.0.10-py3-none-any.whl |
Total release size: 11.9 kB
Release files / xontrib_dalias-0.0.10.tar.gz
| Download URL | xontrib_dalias-0.0.10.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d379030c709e461be807d4509ec0a05d0841891b7f6f8b642a4d336b12b5ded2
|
|
BLAKE2b-256 checksum How to use checksums |
f4446ca4b663c37088c030c2ddbfc954ef80b8f164bae37ae09241d756a6b759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / xontrib_dalias-0.0.10-py3-none-any.whl
| Download URL | xontrib_dalias-0.0.10-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad5cb4c1d597e5e18abde4fa3acbe47bcb7b89bb086777634b163ec5f6eb9c2e
|
|
BLAKE2b-256 checksum How to use checksums |
e140ceba87846fe850f56de34b0cdc5ce5f84a7eec258adac33cee77d6937a98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for xontrib-dalias 0.0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.