{ "info": { "author": "Erik Clarke", "author_email": "ecl@mail.med.upenn.edu", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development", "Topic :: Utilities" ], "description": "argutils - functions for creating matched config files and argument parsers\n===========================================================================\n\n.. image:: https://travis-ci.org/eclarke/argutils.svg?branch=v0.2.0\n :target: https://travis-ci.org/eclarke/argutils\n.. image:: https://coveralls.io/repos/eclarke/argutils/badge.svg?branch=v0.2.0&service=github\n :target: https://coveralls.io/github/eclarke/argutils?branch=master\n.. image:: https://readthedocs.org/projects/argutils/badge/?version=latest\n :target: http://argutils.readthedocs.org/en/latest/?badge=latest\n :alt: Documentation Status\n.. image:: https://badge.fury.io/py/argutils.svg\n :target: https://badge.fury.io/py/argutils\n\n`argutils` provides a set of functions for quickly building command-line programs with matching config files. In particular, instead of separately building an ArgumentParser and ConfigParser, `argutils` lets the user build an interface from a JSON or YAML file, and then uses that to build both an argument parser and matching config file.\n\nInstallation\n------------\n\n.. code-block:: bash\n\n $ pip install argutils\n\nUsage example\n--------------\n\nLet's say we have a toy program that takes three arguments: a message to print, the number of times to print it, and where to print it. We have two files, an argument spec file we'll call `example_spec.yml`, and our program, `example.py`.\n\nIn `example_spec.yml`:\n\n.. code-block:: YAML\n\n _meta:\n help: > \n A program that prints a message some number of times to an output\n file\n message:\n help: the message to print\n default: \"Hello world!\"\n times:\n help: how many times to print the message\n default: 3\n type: int\n output:\n help: where to write the file\n _exclude: True\n default: stdout\n type: File-w\n init:\n help: write a config file with default values\n _exclude: True\n argtype: flag\n\nIn `example.py`:\n\n.. code-block:: Python\n\n try:\n import ConfigParser\n except ImportError:\n import configparser as ConfigParser\n import argutils\n from argutils import (read, export)\n\n SPEC_FILE = 'example_spec.yml'\n CONF_FILE = 'example.cfg'\n\n def main():\n # Used in the config file and argument parser's help\n prog_name = 'example.py'\n\n config = ConfigParser.SafeConfigParser()\n\n # Read the spec and build a parser from it\n argsdict = read.from_yaml(open(SPEC_FILE).read())\n parser = export.to_argparser(prog_name, argsdict)\n\n # If the config file exists and we can read it, use it to set the \n # defaults\n if config.read(CONF_FILE):\n parser = argutils.set_parser_defaults(parser, config)\n\n args = parser.parse_args()\n\n if args.init:\n export.to_config_file(prog_name, argsdict, CONF_FILE)\n\n for _ in range(args.times):\n args.output.write(args.message + '\\n')\n\n\n if __name__ == '__main__':\n main()\n\nLet's see what we've got:\n\n.. code-block:: bash\n\n $ python example.py --help\n usage: example.py [-h] [--message MESSAGE] [--times TIMES]\n [--output OUTPUT] [--init]\n\n A program that prints a message some number of times to an output file\n\n optional arguments:\n -h, --help show this help message and exit\n --message MESSAGE the message to print\n --times TIMES how many times to print the message\n --output OUTPUT where to write the file\n --init write a config file with default values\n\nWe can see that all the arguments we specified in the YAML file are here. Let's write a config file and check that out:\n\n.. code-block:: bash\n\n $ python example.py --init\n $ cat example.cfg\n ## A program that prints a message some number of times to an output file\n [example.py]\n # the message to print\n message = Hello world!\n # how many times to print the message\n times = 3\n\nNote that two arguments don't show up here: `output` and `init`. These were excluded using the `_exclude` flag in the YAML file. This is useful for arguments that shouldn't be set using a config file, including one-time arguments.\n\nLet's test it:\n\n.. code-block:: bash\n\n $ python example.py\n Hello world!\n Hello world!\n Hello world!\n $ python example.py --times 1\n Hello world!\n\nWe can specify the arguments either with command-line flags or by modifying the values in the config file. Values specified on the command line take precedence, followed by the config file values, and resorting to the spec file defaults if nothing else is given.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/eclarke/argutils", "keywords": "", "license": "GPLv2+", "maintainer": "", "maintainer_email": "", "name": "argutils", "package_url": "https://pypi.org/project/argutils/", "platform": "", "project_url": "https://pypi.org/project/argutils/", "project_urls": { "Homepage": "https://github.com/eclarke/argutils" }, "release_url": "https://pypi.org/project/argutils/0.3.3/", "requires_dist": [ "six", "pyyaml" ], "requires_python": "", "summary": "Functions to build matched argument parsers and config files", "version": "0.3.3" }, "last_serial": 4985268, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "bf067bbe179932a266152505d7e2b030", "sha256": "d826e74ded1be7dee9e0a6daf3027a274437f9cab536e323dcc44880a168fd3b" }, "downloads": -1, "filename": "argutils-0.2.0-py2-none-any.whl", "has_sig": false, "md5_digest": "bf067bbe179932a266152505d7e2b030", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9175, "upload_time": "2015-10-30T20:40:48", "url": "https://files.pythonhosted.org/packages/a2/72/db15f2c6d0843c604d7c4361011032217c32233d2c50b0ef5c20aafdba9d/argutils-0.2.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5526b4d346f11fc6166be3e650a6bdb9", "sha256": "6c5e2431381704e86458bd5a5118b24b8596a4401543d9fcb99efeb74f381120" }, "downloads": -1, "filename": "argutils-0.2.0.tar.gz", "has_sig": false, "md5_digest": "5526b4d346f11fc6166be3e650a6bdb9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6243, "upload_time": "2015-10-30T20:40:55", "url": "https://files.pythonhosted.org/packages/64/42/9fee1893bc69c715c6f5f0771113ddd9b6546cebac1e9004381794e8d7db/argutils-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "d4b21cb864c3db95dd77baec52378862", "sha256": "3eab389b1f49755b8148cee435041fd0f111fb33f768ce2a35e02e0ee08bc700" }, "downloads": -1, "filename": "argutils-0.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "d4b21cb864c3db95dd77baec52378862", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9243, "upload_time": "2015-11-13T14:34:54", "url": "https://files.pythonhosted.org/packages/40/47/e2597d2b3c252c86bfbd7cbb87b75ba6fce5fc1be78f6708d6131747821a/argutils-0.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0806f847b782bcee3496d90576bc48f5", "sha256": "5029adfee3ca18bdcf4f20e93a1b5446e6fb85fb5ca987848e920c4e7ba2158d" }, "downloads": -1, "filename": "argutils-0.2.1.tar.gz", "has_sig": false, "md5_digest": "0806f847b782bcee3496d90576bc48f5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6284, "upload_time": "2015-11-13T14:34:59", "url": "https://files.pythonhosted.org/packages/ad/38/8cab242326e13f568b2c1a268e7c6834e35ce6a2342a2723de43738d4279/argutils-0.2.1.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "e79b7a127b6c1fa6eeacd4ac41c73be8", "sha256": "9b508ac935d82b6c0bfe7f7a2861ed417f63939cde263cc63ed216788368809c" }, "downloads": -1, "filename": "argutils-0.3.1-py2-none-any.whl", "has_sig": false, "md5_digest": "e79b7a127b6c1fa6eeacd4ac41c73be8", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9243, "upload_time": "2015-11-02T22:40:38", "url": "https://files.pythonhosted.org/packages/9b/b8/85d82ec277b3134ef3a5520a382739cf67e841afd5a64022f557e83170ef/argutils-0.3.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cc26476881fcaecdf00c646fda8cd325", "sha256": "f0a8c3f15a66b2b611fc05da42511629defaa243affb392208a41d33341e669a" }, "downloads": -1, "filename": "argutils-0.3.1.tar.gz", "has_sig": false, "md5_digest": "cc26476881fcaecdf00c646fda8cd325", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6313, "upload_time": "2015-11-02T22:40:46", "url": "https://files.pythonhosted.org/packages/11/12/6ec101f927ef1e0505bd2f7f3d847c1ea6e5fad2165367235da5a4d55aa6/argutils-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "fce326266184cab1789e5232be2187c7", "sha256": "a5cde672133681ca31703b891d8ac30966f0017119bf763c84fcfbb3b8758cda" }, "downloads": -1, "filename": "argutils-0.3.2-py2-none-any.whl", "has_sig": false, "md5_digest": "fce326266184cab1789e5232be2187c7", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9241, "upload_time": "2015-11-13T14:35:54", "url": "https://files.pythonhosted.org/packages/3e/41/28b9853f24471cc023e37441ca09564c147c6a33345ac429995c35a380d4/argutils-0.3.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31a4c3446b8074ab8c38a9fa9aaacf13", "sha256": "161508fffc0576bf4c744f7bd5f2d2fed5f356875d798acda768923fc55bf03a" }, "downloads": -1, "filename": "argutils-0.3.2.tar.gz", "has_sig": false, "md5_digest": "31a4c3446b8074ab8c38a9fa9aaacf13", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6284, "upload_time": "2015-11-13T14:36:00", "url": "https://files.pythonhosted.org/packages/94/ee/3398f7c6af50ec0327bc714a596939828e65ade7525183d3b2715a54d6fb/argutils-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "2529ae12fa3f96a69bc293d9d09ab047", "sha256": "0ad56e788c2436ee77189f37d72cf22014f209cb40af88a1299ad122e1808421" }, "downloads": -1, "filename": "argutils-0.3.3-py2-none-any.whl", "has_sig": false, "md5_digest": "2529ae12fa3f96a69bc293d9d09ab047", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6863, "upload_time": "2019-03-26T00:10:45", "url": "https://files.pythonhosted.org/packages/34/19/e609917f313d2513b6918edeff17ae952ef0c7b170f9506c1d0072a8a4d8/argutils-0.3.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bf8b81089f5b38fb002dc60b4941a949", "sha256": "3152e6e602847bbcc8868b3adc1284d6008c3dda4bb9b366d7c60778a2538894" }, "downloads": -1, "filename": "argutils-0.3.3.tar.gz", "has_sig": false, "md5_digest": "bf8b81089f5b38fb002dc60b4941a949", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6467, "upload_time": "2019-03-26T00:10:47", "url": "https://files.pythonhosted.org/packages/8e/7f/51286ee6cb8e1c223aa05c2a686f8ef00139bf91969f3109ec8c0d84e67d/argutils-0.3.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2529ae12fa3f96a69bc293d9d09ab047", "sha256": "0ad56e788c2436ee77189f37d72cf22014f209cb40af88a1299ad122e1808421" }, "downloads": -1, "filename": "argutils-0.3.3-py2-none-any.whl", "has_sig": false, "md5_digest": "2529ae12fa3f96a69bc293d9d09ab047", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6863, "upload_time": "2019-03-26T00:10:45", "url": "https://files.pythonhosted.org/packages/34/19/e609917f313d2513b6918edeff17ae952ef0c7b170f9506c1d0072a8a4d8/argutils-0.3.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bf8b81089f5b38fb002dc60b4941a949", "sha256": "3152e6e602847bbcc8868b3adc1284d6008c3dda4bb9b366d7c60778a2538894" }, "downloads": -1, "filename": "argutils-0.3.3.tar.gz", "has_sig": false, "md5_digest": "bf8b81089f5b38fb002dc60b4941a949", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6467, "upload_time": "2019-03-26T00:10:47", "url": "https://files.pythonhosted.org/packages/8e/7f/51286ee6cb8e1c223aa05c2a686f8ef00139bf91969f3109ec8c0d84e67d/argutils-0.3.3.tar.gz" } ] }