{
"info": {
"author": "Michal Krassowski",
"author_email": "krassowski.michal+pypi@gmail.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: User Interfaces",
"Topic :: Utilities"
],
"description": "Declarative Parser\n==================\n\n|Build Status| |Code Climate| |Coverage Status| |Documentation Status|\n\nModern, declarative argument parser for Python 3.6+. Powerful like\nclick, integrated like argparse, declarative as sqlalchemy. MIT\nlicenced. `Documented on\nRTD `__. Install\nwith:\n\n.. code:: bash\n\n python3 -m pip install declarative_parser\n\nAs simple as argparse\n~~~~~~~~~~~~~~~~~~~~~\n\nIt's built on top of argparse - everything you already know stays valid!\n\n.. code:: python\n\n from declarative_parser import Parser, Argument\n\n class MyParser(Parser):\n square = Argument(help='display a square of a given number')\n\n parser = MyParser()\n args = parser.parse_args()\n print(args.square**2)\n\nNested and Parallel\n~~~~~~~~~~~~~~~~~~~\n\nEveryone knows about nested args. What about parallel groups?\n\n.. code:: python\n\n supported_formats = ['png', 'jpeg', 'gif']\n\n class InputOptions(Parser):\n path = Argument(type=argparse.FileType('rb'), optional=False)\n format = Argument(default='png', choices=supported_formats)\n\n class OutputOptions(Parser):\n format = Argument(default='jpeg', choices=supported_formats)\n scale = Argument(type=int, default=100, help='Rescale image to %% of original size')\n\n class ImageConverter(Parser):\n description = 'This app converts images'\n\n verbose = Argument(action='store_true')\n input = InputOptions()\n output = OutputOptions()\n\n parser = ImageConverter()\n\n commands = '--verbose input image.png output --format gif --scale 50'.split()\n\n namespace = parser.parse_args(commands)\n\n assert namespace.input.format == 'png'\n assert namespace.output.format == 'gif'\n\nIntelligent\n~~~~~~~~~~~\n\nMake use of Python 3 type hints to reduce tedious task of parsers\nwriting to two or three lines. Positional, keyword arguments, type\nhints, docstrings - everything can be meaningfully transformed into a\nparser. And if you decide to take control, just overwrite the\nautomatically deduced arguments with an ``Argument()`` defined as a\nclass variable.\n\n.. code:: python\n\n import argparse\n from declarative_parser import Argument\n from declarative_parser.constructor_parser import ConstructorParser\n\n class MyProgram:\n\n database = Argument(\n type=argparse.FileType('r'),\n help='Path to file with the database'\n )\n\n def __init__(self, text: str, threshold: float=0.05, database=None):\n \"\"\"My program does XYZ.\n\n Arguments:\n threshold: a floating-point value defining threshold, default 0.05\n database: file object to the database if any\n \"\"\"\n print(text, threshold, None)\n\n parser = ConstructorParser(MyProgram)\n\n options = parser.parse_args()\n program = parser.constructor(**vars(options))\n\nAnd it works quite intuitively:\n\n.. code:: bash\n\n $ ./my_program.py test --threshold 0.6\n test 0.6 None\n $ ./my_program.py test --threshold f\n usage: my_program.py [-h] [--database DATABASE] [--threshold THRESHOLD] text {} ...\n my_program.py: error: argument --threshold: invalid float value: 'f'\n $ ./my_program.py --threshold 0.6\n usage: my_program.py [-h] [--database DATABASE] [--threshold THRESHOLD] text {} ...\n my_program.py: error: the following arguments are required: text\n\nThree docstring formats are supported: Google, NumPy and\nreStructuredText, with the default being Google.\n\nPS. It works with functions too; see the documentation of\n`FunctionParser `__.\n\nPractical\n~~~~~~~~~\n\nWhat if you only want to show licence of your program? or version? Is\nthere a need to write a separate logic? DeclarativeParser gives you\nutility decorator: ``@action`` which utilizes the power of\n``argparse.Action``, leaving behind the otherwise necessary boilerplate\ncode.\n\n.. code:: python\n\n __version__ = 2.0\n\n import argparse\n from declarative_parser import action\n from declarative_parser.constructor_parser import ConstructorParser\n\n class MyProgram:\n\n def __init__(self, threshold: float=0.05):\n \"\"\"My program does XYZ.\n\n Arguments:\n threshold: a floating-point value, default 0.05\n \"\"\"\n pass\n\n @action\n def version(options):\n print(__version__)\n\n parser = ConstructorParser(MyProgram)\n\n options = parser.parse_args()\n program = parser.constructor(**vars(options))\n\nThe execution of an action will (by default) cause the program to exit\nimmediately when finished.\n\nSee following run as example:\n\n.. code:: bash\n\n $ ./my_program.py --version\n 2.0\n\nSee more examples in `the\ndocumentation `__.\n\n.. |Build Status| image:: https://travis-ci.org/krassowski/declarative-parser.svg?branch=master\n :target: https://travis-ci.org/krassowski/declarative-parser\n.. |Code Climate| image:: https://codeclimate.com/github/krassowski/declarative-parser/badges/gpa.svg\n :target: https://codeclimate.com/github/krassowski/declarative-parser\n.. |Coverage Status| image:: https://coveralls.io/repos/github/krassowski/declarative-parser/badge.svg\n :target: https://coveralls.io/github/krassowski/declarative-parser\n.. |Documentation Status| image:: https://readthedocs.org/projects/declarative-parser/badge/?version=latest\n :target: http://declarative-parser.readthedocs.io/en/latest/?badge=latest",
"description_content_type": "",
"docs_url": null,
"download_url": "https://github.com/krassowski/declarative-parser/tarball/v0.1.3",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/krassowski/declarative-parser",
"keywords": "argument,parser,argparse,declarative,cli",
"license": "MIT",
"maintainer": "",
"maintainer_email": "",
"name": "declarative-parser",
"package_url": "https://pypi.org/project/declarative-parser/",
"platform": "",
"project_url": "https://pypi.org/project/declarative-parser/",
"project_urls": {
"Download": "https://github.com/krassowski/declarative-parser/tarball/v0.1.3",
"Homepage": "https://github.com/krassowski/declarative-parser"
},
"release_url": "https://pypi.org/project/declarative-parser/0.1.3/",
"requires_dist": null,
"requires_python": "",
"summary": "Modern, declarative argument parser for Python 3.6+",
"version": "0.1.3"
},
"last_serial": 3748272,
"releases": {
"0.1": [
{
"comment_text": "",
"digests": {
"md5": "e04462156c08c4cc7ada720a3ae06f50",
"sha256": "863ca0041b7ee3360dce06402649792022a52cba779e97f317c5f56d2c0b0cfc"
},
"downloads": -1,
"filename": "declarative_parser-0.1.tar.gz",
"has_sig": false,
"md5_digest": "e04462156c08c4cc7ada720a3ae06f50",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11031,
"upload_time": "2017-11-25T16:12:09",
"url": "https://files.pythonhosted.org/packages/ed/24/6474bfd71b94a5a73a8555773da59057aeaba191d10e0b3bb0132f730539/declarative_parser-0.1.tar.gz"
}
],
"0.1.1": [
{
"comment_text": "",
"digests": {
"md5": "e6191d6753d41c654036ae99f5abced4",
"sha256": "a71f63dc37ee8b125de60615bb341e543e3e83e2441ee3169fddb0a3a3aca4b9"
},
"downloads": -1,
"filename": "declarative_parser-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "e6191d6753d41c654036ae99f5abced4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11805,
"upload_time": "2017-11-28T23:33:24",
"url": "https://files.pythonhosted.org/packages/6b/88/b57d720b529c1012ed87066805001f1ee9273688b512d90c1fbbca5d70e4/declarative_parser-0.1.1.tar.gz"
}
],
"0.1.2": [
{
"comment_text": "",
"digests": {
"md5": "daa7d366d5c9588669755217dc8c130b",
"sha256": "761e5c34ee45a402869ba8a35a2e8491f36e7249ec1c4141fb721e0c1b58ed80"
},
"downloads": -1,
"filename": "declarative_parser-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "daa7d366d5c9588669755217dc8c130b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12142,
"upload_time": "2017-11-29T00:43:41",
"url": "https://files.pythonhosted.org/packages/37/5f/0c5c7c1c417e949396cc296a57ac7b49b88b9184e4c29631f5cdca02cdcd/declarative_parser-0.1.2.tar.gz"
}
],
"0.1.3": [
{
"comment_text": "",
"digests": {
"md5": "911e0a6e09bf3e9d6512721b4ca89dc5",
"sha256": "3f8fb8b53c7d13243490e5e96095f0b358920895406c70e2cc92af36ac2d6433"
},
"downloads": -1,
"filename": "declarative_parser-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "911e0a6e09bf3e9d6512721b4ca89dc5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12309,
"upload_time": "2018-04-09T11:02:26",
"url": "https://files.pythonhosted.org/packages/bf/c0/63e53bc5fb74a367759052ba6b13622acc345f193eb59a1756f0b96cf512/declarative_parser-0.1.3.tar.gz"
}
],
"0.1b0": [
{
"comment_text": "",
"digests": {
"md5": "dd22472ddcf85cf9ca8f62c2c27147a2",
"sha256": "12fcc6938ce6984d22d162d49521380ce0a8f746a63ce0dc2105066116e39f90"
},
"downloads": -1,
"filename": "declarative_parser-0.1b0.tar.gz",
"has_sig": false,
"md5_digest": "dd22472ddcf85cf9ca8f62c2c27147a2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11109,
"upload_time": "2017-11-28T12:59:58",
"url": "https://files.pythonhosted.org/packages/f9/16/3abf648d2af08c80ea2b325c7867b646e4931072c7acb66fa85a0b105739/declarative_parser-0.1b0.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "911e0a6e09bf3e9d6512721b4ca89dc5",
"sha256": "3f8fb8b53c7d13243490e5e96095f0b358920895406c70e2cc92af36ac2d6433"
},
"downloads": -1,
"filename": "declarative_parser-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "911e0a6e09bf3e9d6512721b4ca89dc5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12309,
"upload_time": "2018-04-09T11:02:26",
"url": "https://files.pythonhosted.org/packages/bf/c0/63e53bc5fb74a367759052ba6b13622acc345f193eb59a1756f0b96cf512/declarative_parser-0.1.3.tar.gz"
}
]
}