Skip to main content

Library of xonsh subprocess specification modifiers.

Project description

Library of xonsh subprocess specification modifiers.

If you like the idea click ⭐ on the repo and tweet.

Installation

To install use pip:

xpip install xontrib-spec-mod
xpip install 'xontrib-spec-mod[dict,yaml]'  # Extra decorators.

Load:

xontrib load spec_mod

Usage

Transform output to object

Default decorators:

  • @lines - return list of lines.
  • @json - json to Python dict.
  • @path - string to pathlib.Path.

Extra decorators:

xpip install 'xontrib-spec-mod[dict,yaml]'
  • @dict - dict-like object (json, JavaScript object, Python dict) to Python dict.
  • @yaml - YAML to Python dict.

Examples

$(@lines ls /)
# ['/bin', '/etc', '/home']

$(@json echo '{"a":1}')  # Try with `curl` ;)
# dict({"a":1})

docker inspect @($(@json docker ps --format json)['ID'])
# Container info

$(@path which xonsh)
# Path('/path/to/xonsh')

$(@path which xonsh).parent
# Path('/path/to')


aliases['ydig'] = '@yaml dig +yaml'  # Update `dig` via `brew install bind` to have `+yaml`.
y = $(ydig google.com)
y[0]['type']
# 'MESSAGE'

Error handling

Default decorators:

  • @err - set $RAISE_SUBPROC_ERROR=True for the command.
  • @noerr - set $RAISE_SUBPROC_ERROR=False for 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xontrib_spec_mod-0.0.5.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xontrib_spec_mod-0.0.5-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file xontrib_spec_mod-0.0.5.tar.gz.

File metadata

  • Download URL: xontrib_spec_mod-0.0.5.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for xontrib_spec_mod-0.0.5.tar.gz
Algorithm Hash digest
SHA256 8a76b3a2433df4c6bc97d35a84d278ab55eba2e42f11970b6929a4e753882b47
MD5 e9abdcce92a17cf459bf1f5d6e1bb7af
BLAKE2b-256 85a0d0f9f69fac317ed2643e63a42b4993153054cf4ca30175b1b56de5e1459d

See more details on using hashes here.

File details

Details for the file xontrib_spec_mod-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_spec_mod-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2038f4b4217d4f3c634104879ca8b6ae5a7a4068e1b20fd0bf55623f73110601
MD5 6fa906593c162d2abefe2bc196b31adb
BLAKE2b-256 1a58770d70cd1e5d223425ca07bf9786c08dbf8e21a1f9df897db0bc0b5f8702

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page