argunparse


Nameargunparse JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/mbdevpl/argunparse
SummaryReversed argparse: generate string of command-line args from Python objects.
upload_time2023-09-02 18:48:06
maintainerMateusz Bysiek
docs_urlNone
authorMateusz Bysiek
requires_python>=3.8
licenseApache License 2.0
keywords argparse commandline arguments pretty printing unparsing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. role:: bash(code)
    :language: bash

.. role:: python(code)
    :language: python


==========
argunparse
==========

Reversed argparse: generate string of command-line args from Python objects.

.. image:: https://img.shields.io/pypi/v/argunparse.svg
    :target: https://pypi.org/project/argunparse
    :alt: package version from PyPI

.. image:: https://github.com/mbdevpl/argunparse/actions/workflows/python.yml/badge.svg?branch=main
    :target: https://github.com/mbdevpl/argunparse/actions
    :alt: build status from GitHub

.. image:: https://codecov.io/gh/mbdevpl/argunparse/branch/main/graph/badge.svg
    :target: https://codecov.io/gh/mbdevpl/argunparse
    :alt: test coverage from Codecov

.. image:: https://api.codacy.com/project/badge/Grade/fd6a7e9ac9324d9f9b5d1e77d10000e4
    :target: https://app.codacy.com/gh/mbdevpl/argunparse
    :alt: grade from Codacy

.. image:: https://img.shields.io/github/license/mbdevpl/argunparse.svg
    :target: https://github.com/mbdevpl/argunparse/blob/v0.1.4/NOTICE
    :alt: license

The *argunparse* is intended to perform an approximate reverse of what *argparse* does. In short:
generating string (or a list of strings) of command-line arguments from a dict and/or a list.

.. contents::
    :backlinks: none


How to use
==========

Simple example of how *argunparse* works:

.. code:: python

    import argunparse

    options = {
        'v': True,
        'long-flag': True,
        'ignored': False,
        'also-ignored': None,
        'o': 'out_file.txt',
        'log': 'log_file.txt'
        }
    args = {
        'in_file.txt'
        }

    unparser = argunparse.ArgumentUnparser()
    print(unparser.unparse(*args, **options))
    # -v --long-flag -o=out_file.txt --log=log_file.txt in_file.txt

    print(unparser.unparse_to_list(*args, **options))
    # ['-v', '--long-flag', '-o=out_file.txt', '--log=log_file.txt', 'in_file.txt']

Special option values are:

*   :python:`True` -- option will be treated as a flag;
*   :python:`False` and :python:`None` -- option will be ignored.

All other values will be converted to strings using :python:`str()`.

For more examples see `examples.ipynb <https://github.com/mbdevpl/argunparse/blob/v0.1.4/examples.ipynb>`_ notebook.


Requirements
============

Python version 3.8 or later.

Python libraries as specified in `requirements.txt <https://github.com/mbdevpl/argunparse/blob/v0.1.4/requirements.txt>`_.

Building and running tests additionally requires packages listed in `requirements_test.txt <https://github.com/mbdevpl/argunparse/blob/v0.1.4/requirements_test.txt>`_.

Tested on Linux, macOS and Windows.


Installation
============

For simplest installation use :bash:`pip`:

.. code:: bash

    pip3 install argunparse

Links
=====

-  *argparse*:

   https://docs.python.org/3/library/argparse.html

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mbdevpl/argunparse",
    "name": "argunparse",
    "maintainer": "Mateusz Bysiek",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "mateusz.bysiek@gmail.com",
    "keywords": "argparse,commandline arguments,pretty printing,unparsing",
    "author": "Mateusz Bysiek",
    "author_email": "mateusz.bysiek@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8b/25/fb83e36339cfee4a6783b676ed4111b71edaf082b13b5eccd0222b01db86/argunparse-0.1.4.tar.gz",
    "platform": null,
    "description": ".. role:: bash(code)\n    :language: bash\n\n.. role:: python(code)\n    :language: python\n\n\n==========\nargunparse\n==========\n\nReversed argparse: generate string of command-line args from Python objects.\n\n.. image:: https://img.shields.io/pypi/v/argunparse.svg\n    :target: https://pypi.org/project/argunparse\n    :alt: package version from PyPI\n\n.. image:: https://github.com/mbdevpl/argunparse/actions/workflows/python.yml/badge.svg?branch=main\n    :target: https://github.com/mbdevpl/argunparse/actions\n    :alt: build status from GitHub\n\n.. image:: https://codecov.io/gh/mbdevpl/argunparse/branch/main/graph/badge.svg\n    :target: https://codecov.io/gh/mbdevpl/argunparse\n    :alt: test coverage from Codecov\n\n.. image:: https://api.codacy.com/project/badge/Grade/fd6a7e9ac9324d9f9b5d1e77d10000e4\n    :target: https://app.codacy.com/gh/mbdevpl/argunparse\n    :alt: grade from Codacy\n\n.. image:: https://img.shields.io/github/license/mbdevpl/argunparse.svg\n    :target: https://github.com/mbdevpl/argunparse/blob/v0.1.4/NOTICE\n    :alt: license\n\nThe *argunparse* is intended to perform an approximate reverse of what *argparse* does. In short:\ngenerating string (or a list of strings) of command-line arguments from a dict and/or a list.\n\n.. contents::\n    :backlinks: none\n\n\nHow to use\n==========\n\nSimple example of how *argunparse* works:\n\n.. code:: python\n\n    import argunparse\n\n    options = {\n        'v': True,\n        'long-flag': True,\n        'ignored': False,\n        'also-ignored': None,\n        'o': 'out_file.txt',\n        'log': 'log_file.txt'\n        }\n    args = {\n        'in_file.txt'\n        }\n\n    unparser = argunparse.ArgumentUnparser()\n    print(unparser.unparse(*args, **options))\n    # -v --long-flag -o=out_file.txt --log=log_file.txt in_file.txt\n\n    print(unparser.unparse_to_list(*args, **options))\n    # ['-v', '--long-flag', '-o=out_file.txt', '--log=log_file.txt', 'in_file.txt']\n\nSpecial option values are:\n\n*   :python:`True` -- option will be treated as a flag;\n*   :python:`False` and :python:`None` -- option will be ignored.\n\nAll other values will be converted to strings using :python:`str()`.\n\nFor more examples see `examples.ipynb <https://github.com/mbdevpl/argunparse/blob/v0.1.4/examples.ipynb>`_ notebook.\n\n\nRequirements\n============\n\nPython version 3.8 or later.\n\nPython libraries as specified in `requirements.txt <https://github.com/mbdevpl/argunparse/blob/v0.1.4/requirements.txt>`_.\n\nBuilding and running tests additionally requires packages listed in `requirements_test.txt <https://github.com/mbdevpl/argunparse/blob/v0.1.4/requirements_test.txt>`_.\n\nTested on Linux, macOS and Windows.\n\n\nInstallation\n============\n\nFor simplest installation use :bash:`pip`:\n\n.. code:: bash\n\n    pip3 install argunparse\n\nLinks\n=====\n\n-  *argparse*:\n\n   https://docs.python.org/3/library/argparse.html\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Reversed argparse: generate string of command-line args from Python objects.",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/mbdevpl/argunparse"
    },
    "split_keywords": [
        "argparse",
        "commandline arguments",
        "pretty printing",
        "unparsing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c359f27e516808c7922e590ce97377956f4badeb7511e9ededafd58f159f48aa",
                "md5": "aa0aa279db864948aee53ae1f2606c81",
                "sha256": "3866a7832984e800e24bdf7f63df35017fb8f16c852f757df9f1958bda168e54"
            },
            "downloads": -1,
            "filename": "argunparse-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa0aa279db864948aee53ae1f2606c81",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9433,
            "upload_time": "2023-09-02T18:48:04",
            "upload_time_iso_8601": "2023-09-02T18:48:04.900061Z",
            "url": "https://files.pythonhosted.org/packages/c3/59/f27e516808c7922e590ce97377956f4badeb7511e9ededafd58f159f48aa/argunparse-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b25fb83e36339cfee4a6783b676ed4111b71edaf082b13b5eccd0222b01db86",
                "md5": "cc0242d346297f975c7491082c938cea",
                "sha256": "94d98668d381a8feff5229e5598a8272a9fa7400427576d1b1f1a8b5ff170acf"
            },
            "downloads": -1,
            "filename": "argunparse-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "cc0242d346297f975c7491082c938cea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10657,
            "upload_time": "2023-09-02T18:48:06",
            "upload_time_iso_8601": "2023-09-02T18:48:06.494539Z",
            "url": "https://files.pythonhosted.org/packages/8b/25/fb83e36339cfee4a6783b676ed4111b71edaf082b13b5eccd0222b01db86/argunparse-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-02 18:48:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mbdevpl",
    "github_project": "argunparse",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "argunparse"
}
        
Elapsed time: 0.10839s