Metadata-Version: 2.1
Name: mario
Version: 0.0.149
Summary: Shell pipes for Python.
Home-page: https://github.com/python-mario/mario
Author: mario contributors
Author-email: mario@example.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Unix
Classifier: Operating System :: POSIX
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Utilities
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
Requires-Dist: click (==7.0)
Requires-Dist: toolz (==0.9.0)
Requires-Dist: attrs (==19.1.0)
Requires-Dist: parso (==0.4.0)
Requires-Dist: bump2version (==0.5.10)
Requires-Dist: trio (==0.11.0)
Requires-Dist: async-generator (==1.10)
Requires-Dist: async-exit-stack (==1.0.1)
Requires-Dist: appdirs (==1.4.3)
Requires-Dist: toml (==0.10.0)
Requires-Dist: asks (==2.3.3)
Requires-Dist: marshmallow (==3.0rc8)
Requires-Dist: pyrsistent (==0.15.2)
Requires-Dist: trio-typing (==0.2.0)
Requires-Dist: docutils (==0.14)
Requires-Dist: sphinx (==2.1.2)
Requires-Dist: pytest (==5.0.1)
Requires-Dist: importlib-metadata (==0.18)
Requires-Dist: xmltodict (==0.12.0)
Requires-Dist: pyyaml (==5.1.1)
Provides-Extra: dev
Requires-Dist: aiohttp (==3.5.4); extra == 'dev'
Requires-Dist: alabaster (==0.7.12); extra == 'dev'
Requires-Dist: ansicolors (==1.0.2); extra == 'dev'
Requires-Dist: anyio (==1.0.0); extra == 'dev'
Requires-Dist: appdirs (==1.4.3); extra == 'dev'
Requires-Dist: argh (==0.26.2); extra == 'dev'
Requires-Dist: asks (==2.3.3); extra == 'dev'
Requires-Dist: asn1crypto (==0.24.0); extra == 'dev'
Requires-Dist: aspy.yaml (==1.3.0); extra == 'dev'
Requires-Dist: astroid (==2.2.5); extra == 'dev'
Requires-Dist: async-generator (==1.10); extra == 'dev'
Requires-Dist: async-timeout (==3.0.1); extra == 'dev'
Requires-Dist: async-exit-stack (==1.0.1); extra == 'dev'
Requires-Dist: atomicwrites (==1.3.0); extra == 'dev'
Requires-Dist: attrs (==19.1.0); extra == 'dev'
Requires-Dist: automat (==0.7.0); extra == 'dev'
Requires-Dist: babel (==2.6.0); extra == 'dev'
Requires-Dist: black (==19.3b0); extra == 'dev'
Requires-Dist: bleach (==3.1.0); extra == 'dev'
Requires-Dist: bump2version (==0.5.10); extra == 'dev'
Requires-Dist: certifi (==2019.3.9); extra == 'dev'
Requires-Dist: cffi (==1.12.2); extra == 'dev'
Requires-Dist: cfgv (==2.0.1); extra == 'dev'
Requires-Dist: chardet (==3.0.4); extra == 'dev'
Requires-Dist: click (==7.0); extra == 'dev'
Requires-Dist: constantly (==15.1.0); extra == 'dev'
Requires-Dist: coverage (==4.5.3); extra == 'dev'
Requires-Dist: cryptography (==2.6.1); extra == 'dev'
Requires-Dist: cuvner (==18.0.1); extra == 'dev'
Requires-Dist: docshtest (==0.0.2); extra == 'dev'
Requires-Dist: docutils (==0.14); extra == 'dev'
Requires-Dist: filelock (==3.0.10); extra == 'dev'
Requires-Dist: h11 (==0.9.0); extra == 'dev'
Requires-Dist: hyperlink (==19.0.0); extra == 'dev'
Requires-Dist: hypothesis (==4.17.1); extra == 'dev'
Requires-Dist: identify (==1.4.5); extra == 'dev'
Requires-Dist: idna (==2.8); extra == 'dev'
Requires-Dist: imagesize (==1.1.0); extra == 'dev'
Requires-Dist: importlib-metadata (==0.18); extra == 'dev'
Requires-Dist: incremental (==17.5.0); extra == 'dev'
Requires-Dist: isort (==4.3.17); extra == 'dev'
Requires-Dist: jedi (==0.13.3); extra == 'dev'
Requires-Dist: jinja2 (==2.10.1); extra == 'dev'
Requires-Dist: lazy-object-proxy (==1.3.1); extra == 'dev'
Requires-Dist: lockfile (==0.12.2); extra == 'dev'
Requires-Dist: lxml (==4.3.4); extra == 'dev'
Requires-Dist: markupsafe (==1.1.1); extra == 'dev'
Requires-Dist: marshmallow-jsonschema (==0.6.0); extra == 'dev'
Requires-Dist: marshmallow (==3.0.0rc8); extra == 'dev'
Requires-Dist: mccabe (==0.6.1); extra == 'dev'
Requires-Dist: more-itertools (==7.0.0); extra == 'dev'
Requires-Dist: multidict (==4.5.2); extra == 'dev'
Requires-Dist: mypy-extensions (==0.4.1); extra == 'dev'
Requires-Dist: mypy (==0.720); extra == 'dev'
Requires-Dist: nodeenv (==1.3.3); extra == 'dev'
Requires-Dist: outcome (==1.0.0); extra == 'dev'
Requires-Dist: packaging (==19.0); extra == 'dev'
Requires-Dist: parso (==0.4.0); extra == 'dev'
Requires-Dist: pathtools (==0.1.2); extra == 'dev'
Requires-Dist: pkginfo (==1.5.0.1); extra == 'dev'
Requires-Dist: pluggy (==0.12.0); extra == 'dev'
Requires-Dist: pre-commit (==1.17.0); extra == 'dev'
Requires-Dist: py (==1.8.0); extra == 'dev'
Requires-Dist: pyasn1-modules (==0.2.4); extra == 'dev'
Requires-Dist: pyasn1 (==0.4.5); extra == 'dev'
Requires-Dist: pycparser (==2.19); extra == 'dev'
Requires-Dist: pygments (==2.4.2); extra == 'dev'
Requires-Dist: pyhamcrest (==1.9.0); extra == 'dev'
Requires-Dist: pylint (==2.3.1); extra == 'dev'
Requires-Dist: pyopenssl (==19.0.0); extra == 'dev'
Requires-Dist: pyparsing (==2.4.0); extra == 'dev'
Requires-Dist: pyrsistent (==0.15.2); extra == 'dev'
Requires-Dist: pytest-clarity (==0.1.0a1); extra == 'dev'
Requires-Dist: pytest-cov (==2.6.1); extra == 'dev'
Requires-Dist: pytest-sugar (==0.9.2); extra == 'dev'
Requires-Dist: pytest (==5.0.1); extra == 'dev'
Requires-Dist: pytz (==2019.1); extra == 'dev'
Requires-Dist: pyyaml (==5.1.1); extra == 'dev'
Requires-Dist: readme-renderer (==24.0); extra == 'dev'
Requires-Dist: requests-toolbelt (==0.8.0); extra == 'dev'
Requires-Dist: requests (==2.21.0); extra == 'dev'
Requires-Dist: service-identity (==18.1.0); extra == 'dev'
Requires-Dist: six (==1.12.0); extra == 'dev'
Requires-Dist: sniffio (==1.1.0); extra == 'dev'
Requires-Dist: snowballstemmer (==1.2.1); extra == 'dev'
Requires-Dist: sortedcontainers (==2.1.0); extra == 'dev'
Requires-Dist: sphinx-rtd-theme (==0.4.3); extra == 'dev'
Requires-Dist: sphinx (==2.1.2); extra == 'dev'
Requires-Dist: sphinxcontrib-applehelp (==1.0.1); extra == 'dev'
Requires-Dist: sphinxcontrib-devhelp (==1.0.1); extra == 'dev'
Requires-Dist: sphinxcontrib-htmlhelp (==1.0.2); extra == 'dev'
Requires-Dist: sphinxcontrib-jsmath (==1.0.1); extra == 'dev'
Requires-Dist: sphinxcontrib-qthelp (==1.0.2); extra == 'dev'
Requires-Dist: sphinxcontrib-serializinghtml (==1.1.3); extra == 'dev'
Requires-Dist: termcolor (==1.1.0); extra == 'dev'
Requires-Dist: toml (==0.10.0); extra == 'dev'
Requires-Dist: toolz (==0.9.0); extra == 'dev'
Requires-Dist: tox (==3.9.0); extra == 'dev'
Requires-Dist: tqdm (==4.31.1); extra == 'dev'
Requires-Dist: treq (==18.6.0); extra == 'dev'
Requires-Dist: trio (==0.11.0); extra == 'dev'
Requires-Dist: trio-typing (==0.2.0); extra == 'dev'
Requires-Dist: twine (==1.13.0); extra == 'dev'
Requires-Dist: twisted[tls] (==19.2.0); extra == 'dev'
Requires-Dist: typed-ast (==1.4.0); extra == 'dev'
Requires-Dist: typing-extensions (==3.7.4); extra == 'dev'
Requires-Dist: unidiff (==0.5.5); extra == 'dev'
Requires-Dist: urllib3 (==1.24.2); extra == 'dev'
Requires-Dist: virtualenv (==16.4.3); extra == 'dev'
Requires-Dist: vulture (==1.0); extra == 'dev'
Requires-Dist: watchdog (==0.9.0); extra == 'dev'
Requires-Dist: wcwidth (==0.1.7); extra == 'dev'
Requires-Dist: webencodings (==0.5.1); extra == 'dev'
Requires-Dist: wrapt (==1.11.1); extra == 'dev'
Requires-Dist: xmltodict (==0.12.0); extra == 'dev'
Requires-Dist: yapf (==0.27.0); extra == 'dev'
Requires-Dist: yarl (==1.3.0); extra == 'dev'
Requires-Dist: zipp (==0.5.2); extra == 'dev'
Requires-Dist: zope.interface (==4.6.0); extra == 'dev'

``````````````````````````````````````````````````````
Mario: Shell pipes in Python
``````````````````````````````````````````````````````

Have you ever wanted to use Python functions directly in your Unix shell? Mario can read and write csv, json, and yaml; traverse trees, and even do xpath queries. Plus, it supports async commands right out of the box. Build your own commands with a simple configuration file, and install plugins for even more!

Mario is the plumbing snake 🐍🔧 helping you build data pipelines in your shell 🐢.


.. image:: https://img.shields.io/github/stars/python-mario/mario?style=social
   :target: https://github.com/python-mario/mario
   :alt: GitHub

.. image:: https://readthedocs.org/projects/python-mario/badge/?style=flat
   :target: https://readthedocs.org/projects/python-mario
   :alt: Documentation Status

.. image:: https://img.shields.io/travis/com/python-mario/mario/master
   :target: https://travis-ci.com/python-mario/mario#
   :alt: Build status

.. image:: https://img.shields.io/pypi/v/mario.svg
   :target: https://pypi.python.org/pypi/mario
   :alt: PyPI package

.. image:: https://img.shields.io/codecov/c/github/python-mario/mario.svg
   :target: https://codecov.io/gh/python-mario/mario
   :alt: Coverage



&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Features
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


- Execute Python code in your shell.
- Pass Python objects through multi-stage pipelines.
- Read and write csv, json, yaml, toml, xml.
- Run async functions natively.
- Define your own commands in a simple configuration file or by writing Python code.
- Install plugins to get more commands.
- Codebase maintains high test coverage, continuous integration, and nightly releases.


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Installation
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


..
    installation-inclusion-start

Mario
***********************************************************


Windows support is hopefully coming soon. Linux and MacOS are supported now.

Get Mario with pip:

.. code-block:: bash

   python3.7 -m pip install mario

If you're not inside a virtualenv, you might get a ``PermissionsError``. In that case, try using:

.. code-block:: bash

    python3.7 -m pip install --user mario

or for more isolation, use `pipx <https://github.com/pipxproject/pipx/>`_:

.. code-block:: bash

     pipx install --python python3.7 mario



Mario addons
***********************************************************

The `mario-addons <https://mario-addons.readthedocs.io/>`__ package provides a number of useful commands not found in the base collection.


Get Mario addons with pip:

.. code-block:: bash

   python3.7 -m pip install mario-addons

If you're not inside a virtualenv, you might get a ``PermissionsError``. In that case, try using:

.. code-block:: bash

    python3.7 -m pip install --user mario-addons

or for more isolation, use `pipx <https://github.com/pipxproject/pipx/>`_:

.. code-block:: bash

     pipx install --python python3.7 mario
     pipx inject mario mario-addons



..
    installation-inclusion-end




&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Quickstart
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

Basics
***********************************************************

Invoke with  ``mario`` at the command line.

.. code-block:: bash

  $ mario eval 1+1
  2


Given a csv like this:


.. code-block:: bash

    $ cat <<EOF > hackers.csv
    name,age
    Alice,21
    Bob,22
    Carol,23
    EOF

Use ``read-csv-dicts`` to read each row into a dict:

.. code-block:: bash

    $ mario read-csv-dicts < hackers.csv
    {'name': 'Alice', 'age': '21'}
    {'name': 'Bob', 'age': '22'}
    {'name': 'Carol', 'age': '23'}


Use ``map`` to act on each input item ``x`` :

.. code-block:: bash

    $ mario read-csv-dicts map 'x["name"]' < hackers.csv
    Alice
    Bob
    Carol

Chain python functions together with ``!``:

.. code-block:: bash

    $ mario read-csv-dicts map 'x["name"] ! len' < hackers.csv
    5
    3
    5

or by adding another command

.. code-block:: bash

    $ mario read-csv-dicts map 'x["name"]' map len < hackers.csv
    5
    3
    5


Use ``x`` as a placeholder for the input at each stage:

.. code-block:: bash

    $ mario read-csv-dicts map 'x["age"] ! int ! x*2'  < hackers.csv
    42
    44
    46


Automatically import modules you need:

.. code-block:: bash

    $ mario map 'collections.Counter ! dict' <<<mississippi
    {'m': 1, 'i': 4, 's': 4, 'p': 2}


You don't need to explicitly call the function with ``some_function(x)``; just use the function's name, ``some_function``. For example, instead of

.. code-block:: bash

  $ mario map 'len(x)' <<<'a\nbb'
  5

try

.. code-block:: bash

  $ mario map len <<<'a\nbb'
  5




More commands
***********************************************************

Here are a few commands. See `Command reference <https://python-mario.readthedocs.io/en/latest/cli_reference.html>`_ for the complete set, and get even more from `mario-addons <https://mario-addons.readthedocs.org/>`__.


``eval``
----------------------------------------------------


Use ``eval`` to evaluate a Python expression.

.. code-block:: bash

  $ mario eval 'datetime.datetime.utcnow()'
  2019-01-01 01:23:45.562736



``map``
----------------------------------------------------

Use ``map`` to act on each input item.

.. code-block:: bash

   $ mario map 'x * 2' <<<'a\nbb\n'
   aa
   bbbb

``filter``
----------------------------------------------------


Use ``filter`` to evaluate a condition on each line of input and exclude false values.

.. code-block:: bash

   $  mario filter 'len(x) > 1' <<<'a\nbb\nccc\n'
   bb
   ccc


``apply``
----------------------------------------------------

Use ``apply`` to act on the sequence of items.

.. code-block:: bash

    $ mario apply 'len(x)' <<<$'a\nbb'
    2




``chain``
----------------------------------------------------

Use ``chain`` to flatten an iterable of iterables of items into an iterable of items, like `itertools.chain.from_iterable <https://docs.python.org/3/library/itertools.html#itertools.chain.from_iterable>`_.

For example, after calculating a several rows of items,

.. code-block:: bash


    $ mario  map 'x*2 ! [x[i:i+2] for i in range(len(x))]'   <<EOF
    ab
    ce
    EOF
    ['ab', 'ba', 'ab', 'b']
    ['ce', 'ec', 'ce', 'e']


use ``chain`` to put each item on its own row:

.. code-block:: bash

    $ mario  map 'x*2 ! [x[i:i+2] for i in range(len(x))]' chain  <<EOF
    ab
    ce
    EOF
    ab
    ba
    ab
    b
    ce
    ec
    ce
    e

Then subsequent commands will act on these new rows. Here we get the length of each row.

.. code-block:: bash

    $ mario  map 'x*2 ! [x[i:i+2] for i in range(len(x))]' chain map len <<EOF
    ab
    ce
    EOF
    2
    2
    2
    1
    2
    2
    2
    1



``async-map``
----------------------------------------------------

..
    async-inclusion-start

Making sequential requests is slow. These requests take 16 seconds to complete.

.. code-block:: bash


       % time mario map 'await asks.get ! x.json()["url"]'  <<EOF
       http://httpbin.org/delay/5
       http://httpbin.org/delay/1
       http://httpbin.org/delay/2
       http://httpbin.org/delay/3
       http://httpbin.org/delay/4
       EOF
       https://httpbin.org/delay/5
       https://httpbin.org/delay/1
       https://httpbin.org/delay/2
       https://httpbin.org/delay/3
       https://httpbin.org/delay/4
       0.51s user
       0.02s system
       16.460 total


Concurrent requests can go much faster. The same requests now take only 6 seconds. Use ``async-map``, or ``async-filter``, or ``reduce`` with ``await some_async_function`` to get concurrency out of the box.


.. code-block:: bash


       % time mario async-map 'await asks.get ! x.json()["url"]'  <<EOF
       http://httpbin.org/delay/5
       http://httpbin.org/delay/1
       http://httpbin.org/delay/2
       http://httpbin.org/delay/3
       http://httpbin.org/delay/4
       EOF
       https://httpbin.org/delay/5
       https://httpbin.org/delay/1
       https://httpbin.org/delay/2
       https://httpbin.org/delay/3
       https://httpbin.org/delay/4
       0.49s user
       0.03s system
       5.720 total

..
    async-inclusion-end

.. _config-intro:

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Configuration
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


Define new commands and set default options. See `Configuration reference <config_reference.html>`_ for details.


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Plugins
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

Add new commands like ``map`` and ``reduce`` by installing Mario plugins. You can try them out without installing by adding them to any ``.py`` file in your ``~/.config/mario/modules/``.

Share popular commands by installing the `mario-addons <https://mario-addons.readthedocs.io/en/latest/readme.html>`_ package.



&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Q & A
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


..
    Q&A-inclusion-start



What's the status of this package?
***********************************************************

* This package is experimental and is subject to change without notice.
* Check the `issues page <https://www.github.com/python-mario/mario/issues>`_ for open tickets.


Why another package?
***********************************************************

A number of cool projects have pioneered in the Python-in-shell space. I wrote Mario because I didn't know these existed at the time, but now Mario has a bunch of features the others don't (user configuration, multi-stage pipelines, async, plugins, etc).

* https://github.com/Russell91/pythonpy
* http://gfxmonk.net/dist/doc/piep/
* https://spy.readthedocs.io/en/latest/intro.html
* https://github.com/ksamuel/Pyped
* https://github.com/ircflagship2/pype


..
    Q&A-inclusion-end


