{ "info": { "author": "Thomas Levine", "author_email": "_@thomaslevine.com", "bugtrack_url": null, "classifiers": [], "description": "Blargparse extends ``argparse.ArgumentParser``,\nadding an ``add_aggregate`` method that can help you separate\nyour user interface logic from everything else.\n\nHow to use\n-----------\n\nInstall from PyPI. ::\n\n pip install blargparse\n\nHere's the simplest way to use it. ::\n\n b = BlargParser()\n b.add_argument('--left', '-l', type = int, default = 0)\n b.add_argument('--right', 'r', type = int, default = 100)\n b.add_aggregate('numbers', lambda args: range(args.left, args.right))\n\n b.parse_args([]).numbers == range(0, 100)\n\nYou can get a bit fancier. ::\n\n b = BlargParser()\n b.add_argument('--left', '-l', type = int, default = 0)\n b.add_argument('--right', 'r', type = int, default = 100)\n def f(args):\n output = range(args.left, args.right)\n del(args.left, args.right)\n b.add_aggregate(f)\n\n b.parse_args([]).numbers == range(0, 100)\n\nWhy\n--------\nI wrote Blargparse because I found myself doing stuff like this. ::\n\n # Construct the parser.\n a = argparse.ArgumentParser()\n a.add_argument('--left', '-l', type = int, default = 0)\n a.add_argument('--right', 'r', type = int, default = 100)\n \n # Parse the arguments\n import sys\n ns = a.parse_args(sys.argv)\n\n # Convert them into the form I want for my application.\n numbers = range(ns.left, ns.right)\n\nThe input argument that made most sense to me while programming the\nthing was the ``numbers`` range, but I thought it was easiest if the\nend user could specify this range as a combination of ``--left`` and\n``--right`` flags. And I might want to change that based on what\nusers seem to prefer.\n\nThe above approach is fine because it's small, but I had several\narguments like this spread across several subparsers in different places,\nand the construction, parsing, and conversion of the arguments thus\nwound up spread across functions and even files.\n\nWith vanilla ``argparse`` I wound up doing stuff like this. ::\n\n def _build_subparsers(argparser):\n 'This adds subparsers to the parser.'\n subparsers = argparser.add_subparsers()\n # ...\n\n def _apply_aggregates(args):\n args.range = range(args.left, args.right)\n del(args.left, args.right)\n\n argparser = argparser.ArgumentParser()\n _build_subparsers(argparser)\n args = argparser.parse_args()\n _apply_aggregates(args)\n\nThis is a bit better except that it groups subparsers together and\naggregates together. I wanted subparsers to be grouped with relevant\naggregates, and I did not want to group by whether something was a\nsubparser or an aggregate; I think of the aggregates as components of\nthe subparsers.\n\nA more confusing alternative would have been to come up with my own\nnon-argparse interface on top of this for specifying groupings of\nsubparsers and aggregates.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tlevine/blargparse", "keywords": null, "license": "LGPL", "maintainer": null, "maintainer_email": null, "name": "blargparse", "package_url": "https://pypi.org/project/blargparse/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/blargparse/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/tlevine/blargparse" }, "release_url": "https://pypi.org/project/blargparse/0.0.3/", "requires_dist": null, "requires_python": null, "summary": "Combine arguments inside your blargument parser.", "version": "0.0.3" }, "last_serial": 1669823, "releases": { "0.0.1": [], "0.0.2": [ { "comment_text": "", "digests": { "md5": "37daa8645721bba5ae64a00fd138f548", "sha256": "e590826b19ce67ec257cf9b5032c239ef012b9b5d296eafcc34ce1be57cf50cb" }, "downloads": -1, "filename": "blargparse-0.0.2.tar.gz", "has_sig": false, "md5_digest": "37daa8645721bba5ae64a00fd138f548", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2072, "upload_time": "2015-08-08T17:41:59", "url": "https://files.pythonhosted.org/packages/a2/8c/5f9015e5da4ae8f6d1d759045129dc3b5d1034267e1a7750cf869dbfc9f3/blargparse-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "e10d5653da84cdf70bce342f2c7887d7", "sha256": "7592d9607d48242cff024c2d4da798e5ee27f65864709392b7690f6bd397611c" }, "downloads": -1, "filename": "blargparse-0.0.3.tar.gz", "has_sig": false, "md5_digest": "e10d5653da84cdf70bce342f2c7887d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2121, "upload_time": "2015-08-08T19:36:45", "url": "https://files.pythonhosted.org/packages/bf/b5/b04ef8247a09fe8a1a6074c176e991b777b0a71af7ac54eb2d2ebdd2d1db/blargparse-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e10d5653da84cdf70bce342f2c7887d7", "sha256": "7592d9607d48242cff024c2d4da798e5ee27f65864709392b7690f6bd397611c" }, "downloads": -1, "filename": "blargparse-0.0.3.tar.gz", "has_sig": false, "md5_digest": "e10d5653da84cdf70bce342f2c7887d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2121, "upload_time": "2015-08-08T19:36:45", "url": "https://files.pythonhosted.org/packages/bf/b5/b04ef8247a09fe8a1a6074c176e991b777b0a71af7ac54eb2d2ebdd2d1db/blargparse-0.0.3.tar.gz" } ] }