{"id":13468774,"url":"https://github.com/python-mario/mario","last_synced_at":"2025-03-26T05:31:20.982Z","repository":{"id":45116870,"uuid":"185277224","full_name":"python-mario/mario","owner":"python-mario","description":"Powerful Python pipelines for your shell ","archived":false,"fork":false,"pushed_at":"2022-01-07T06:40:21.000Z","size":1812,"stargazers_count":507,"open_issues_count":43,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-01T14:18:02.494Z","etag":null,"topics":["async","cli","pipes","plugins","python","shell","unix"],"latest_commit_sha":null,"homepage":"https://python-mario.readthedocs.io ","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/python-mario.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-06T21:54:41.000Z","updated_at":"2025-02-01T18:56:13.000Z","dependencies_parsed_at":"2022-09-14T07:22:17.144Z","dependency_job_id":null,"html_url":"https://github.com/python-mario/mario","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-mario%2Fmario","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-mario%2Fmario/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-mario%2Fmario/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-mario%2Fmario/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-mario","download_url":"https://codeload.github.com/python-mario/mario/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245597305,"owners_count":20641865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","cli","pipes","plugins","python","shell","unix"],"created_at":"2024-07-31T15:01:18.838Z","updated_at":"2025-03-26T05:31:20.031Z","avatar_url":"https://github.com/python-mario.png","language":"Python","readme":"``````````````````````````````````````````````````````\nMario: Shell pipes in Python\n``````````````````````````````````````````````````````\n\n\n\n.. image:: https://img.shields.io/github/stars/python-mario/mario?style=social\n   :target: https://github.com/python-mario/mario\n   :alt: GitHub\n\n.. image:: https://readthedocs.org/projects/python-mario/badge/?style=flat\n   :target: https://readthedocs.org/projects/python-mario\n   :alt: Documentation Status\n\n.. image:: https://img.shields.io/travis/com/python-mario/mario/master\n   :target: https://travis-ci.com/python-mario/mario#\n   :alt: Build status\n\n.. image:: https://img.shields.io/pypi/v/mario.svg\n   :target: https://pypi.python.org/pypi/mario\n   :alt: PyPI package\n\n.. image:: https://img.shields.io/codecov/c/github/python-mario/mario.svg\n   :target: https://codecov.io/gh/python-mario/mario\n   :alt: Coverage\n\nHave 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!\n\nMario is the plumbing snake 🐍🔧 helping you build data pipelines in your shell 🐢.\n\n\n.. image:: https://raw.githubusercontent.com/python-mario/mario/master/docs/time.png\n   :alt: What time is it in Sydney?\n\n\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\nFeatures\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\n\n\n- Execute Python code in your shell.\n- Pass Python objects through multi-stage pipelines.\n- Read and write csv, json, yaml, toml, xml.\n- Run async functions natively.\n- Define your own commands in a simple configuration file or by writing Python code.\n- Install plugins to get more commands.\n- Enjoy high test coverage, continuous integration, and nightly releases.\n\n\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\nInstallation\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\n\n\n..\n    installation-inclusion-start\n\nMario\n***********************************************************\n\n\nWindows support is hopefully coming soon. Linux and MacOS are supported now.\n\nGet Mario with pip:\n\n.. code-block:: bash\n\n   python3.7 -m pip install mario\n\nIf you're not inside a virtualenv, you might get a ``PermissionsError``. In that case, try using:\n\n.. code-block:: bash\n\n    python3.7 -m pip install --user mario\n\nor for more isolation, use `pipx \u003chttps://github.com/pipxproject/pipx/\u003e`_:\n\n.. code-block:: bash\n\n     pipx install --python python3.7 mario\n\n\n\nMario addons\n***********************************************************\n\nThe `mario-addons \u003chttps://mario-addons.readthedocs.io/\u003e`__ package provides a number of useful commands not found in the base collection.\n\n\nGet Mario addons with pip:\n\n.. code-block:: bash\n\n   python3.7 -m pip install mario-addons\n\nIf you're not inside a virtualenv, you might get a ``PermissionsError``. In that case, try using:\n\n.. code-block:: bash\n\n    python3.7 -m pip install --user mario-addons\n\nor for more isolation, use `pipx \u003chttps://github.com/pipxproject/pipx/\u003e`_:\n\n.. code-block:: bash\n\n     pipx install --python python3.7 mario\n     pipx inject mario mario-addons\n\n\n\n..\n    installation-inclusion-end\n\n\n\n\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\nQuickstart\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\n\nBasics\n***********************************************************\n\nInvoke with  ``mario`` at the command line.\n\n.. code-block:: bash\n\n    $ mario eval 1+1\n    2\n\n\nGiven a csv like this:\n\n\n.. code-block:: bash\n\n    $ cat \u003c\u003cEOF \u003e hackers.csv\n    name,age\n    Alice,21\n    Bob,22\n    Carol,23\n    EOF\n\nUse ``read-csv-dicts`` to read each row into a dict:\n\n.. code-block:: bash\n\n    $ mario read-csv-dicts \u003c hackers.csv\n    {'name': 'Alice', 'age': '21'}\n    {'name': 'Bob', 'age': '22'}\n    {'name': 'Carol', 'age': '23'}\n\n\nUse ``map`` to act on each input item ``x`` :\n\n.. code-block:: bash\n\n    $ mario read-csv-dicts map 'x[\"name\"]' \u003c hackers.csv\n    Alice\n    Bob\n    Carol\n\nChain Python functions together with ``!``:\n\n.. code-block:: bash\n\n    $ mario read-csv-dicts map 'x[\"name\"] ! len' \u003c hackers.csv\n    5\n    3\n    5\n\nor by adding another command\n\n.. code-block:: bash\n\n    $ mario read-csv-dicts map 'x[\"name\"]' map len \u003c hackers.csv\n    5\n    3\n    5\n\n\nUse ``x`` as a placeholder for the input at each stage:\n\n.. code-block:: bash\n\n    $ mario read-csv-dicts map 'x[\"age\"] ! int ! x*2'  \u003c hackers.csv\n    42\n    44\n    46\n\n\nAutomatically import modules you need:\n\n.. code-block:: bash\n\n    $ mario map 'collections.Counter ! dict' \u003c\u003c\u003cmississippi\n    {'m': 1, 'i': 4, 's': 4, 'p': 2}\n\n\nYou don't need to explicitly call the function with ``some_function(x)``; just use the function's name, ``some_function``. For example, instead of\n\n.. code-block:: bash\n\n    $ mario map 'len(x)' \u003c\u003cEOF\n    a\n    bb\n    EOF\n    1\n    2\n\ntry\n\n.. code-block:: bash\n\n    $ mario map len \u003c\u003cEOF\n    a\n    bb\n    EOF\n    1\n    2\n\n\n\n\nMore commands\n***********************************************************\n\nHere are a few commands. See `Command reference \u003chttps://python-mario.readthedocs.io/en/latest/cli_reference.html\u003e`_ for the complete set, and get even more from `mario-addons \u003chttps://mario-addons.readthedocs.org/\u003e`__.\n\n\n``eval``\n----------------------------------------------------\n\n\nUse ``eval`` to evaluate a Python expression.\n\n.. code-block:: bash\n\n    % mario eval 'datetime.datetime.utcnow()'\n   2019-01-01 01:23:45.562736\n\n\n\n``map``\n----------------------------------------------------\n\nUse ``map`` to act on each input item.\n\n.. code-block:: bash\n\n    $ mario map 'x * 2' \u003c\u003cEOF\n    a\n    bb\n    EOF\n    aa\n    bbbb\n\n``filter``\n----------------------------------------------------\n\n\nUse ``filter`` to evaluate a condition on each line of input and exclude false values.\n\n.. code-block:: bash\n\n    $ mario filter 'len(x) \u003e 1' \u003c\u003cEOF\n    a\n    bb\n    ccc\n    EOF\n    bb\n    ccc\n\n\n``apply``\n----------------------------------------------------\n\nUse ``apply`` to act on the sequence of items.\n\n.. code-block:: bash\n\n    $ mario apply 'len(x)' \u003c\u003cEOF\n    a\n    bb\n    EOF\n    2\n\n\n\n\n``chain``\n----------------------------------------------------\n\nUse ``chain`` to flatten a list of lists into a single list, like `itertools.chain.from_iterable \u003chttps://docs.python.org/3/library/itertools.html#itertools.chain.from_iterable\u003e`_.\n\nFor example, after generating a several rows of items,\n\n.. code-block:: bash\n\n\n    $ mario read-csv-tuples \u003c\u003cEOF\n    a,b,c\n    d,e,f\n    g,h,i\n    EOF\n    ('a', 'b', 'c')\n    ('d', 'e', 'f')\n    ('g', 'h', 'i')\n\n\n\nuse ``chain`` to put each item on its own row:\n\n.. code-block:: bash\n\n    $ mario read-csv-tuples chain \u003c\u003cEOF\n    a,b,c\n    d,e,f\n    g,h,i\n    EOF\n    a\n    b\n    c\n    d\n    e\n    f\n    g\n    h\n    i\n\n\n\n``async-map``\n----------------------------------------------------\n\n..\n    async-inclusion-start\n\nMaking sequential requests is slow. These requests take 16 seconds to complete.\n\n.. code-block:: bash\n\n\n       % time mario map 'await asks.get ! x.json()[\"url\"]'  \u003c\u003cEOF\n       http://httpbin.org/delay/5\n       http://httpbin.org/delay/1\n       http://httpbin.org/delay/2\n       http://httpbin.org/delay/3\n       http://httpbin.org/delay/4\n       EOF\n       https://httpbin.org/delay/5\n       https://httpbin.org/delay/1\n       https://httpbin.org/delay/2\n       https://httpbin.org/delay/3\n       https://httpbin.org/delay/4\n       0.51s user\n       0.02s system\n       16.460 total\n\n\nConcurrent 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.\n\n\n.. code-block:: bash\n\n\n       % time mario async-map 'await asks.get ! x.json()[\"url\"]'  \u003c\u003cEOF\n       http://httpbin.org/delay/5\n       http://httpbin.org/delay/1\n       http://httpbin.org/delay/2\n       http://httpbin.org/delay/3\n       http://httpbin.org/delay/4\n       EOF\n       https://httpbin.org/delay/5\n       https://httpbin.org/delay/1\n       https://httpbin.org/delay/2\n       https://httpbin.org/delay/3\n       https://httpbin.org/delay/4\n       0.49s user\n       0.03s system\n       5.720 total\n\n..\n    async-inclusion-end\n\n.. _config-intro:\n\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\nConfiguration\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\n\n\nDefine new commands and set default options. See `Configuration reference \u003chttps://python-mario.readthedocs.io/en/latest/config_reference.html\u003e`_ for details.\n\n\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\nPlugins\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\n\nAdd 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/``.\n\nShare popular commands by installing the `mario-addons \u003chttps://mario-addons.readthedocs.io/en/latest/readme.html\u003e`_ package.\n\n\n\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\nQ \u0026 A\n\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\u0026\n\n\n..\n    Q\u0026A-inclusion-start\n\n\n\nWhat's the status of this package?\n***********************************************************\n\n* This package is experimental and is subject to change without notice.\n* Check the `issues page \u003chttps://www.github.com/python-mario/mario/issues\u003e`_ for open tickets.\n\n\nWhy another package?\n***********************************************************\n\nA 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).\n\n* https://github.com/Russell91/pythonpy\n* http://gfxmonk.net/dist/doc/piep/\n* https://spy.readthedocs.io/en/latest/intro.html\n* https://github.com/ksamuel/Pyped\n* https://github.com/ircflagship2/pype\n* https://code.google.com/archive/p/pyp/\n\n\n..\n    Q\u0026A-inclusion-end\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-mario%2Fmario","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-mario%2Fmario","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-mario%2Fmario/lists"}