{ "info": { "author": "Aaron Iles", "author_email": "aaron.iles@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "======\nbegins\n======\n\n--------\nOverview\n--------\n\nCommand line programs for *lazy* humans.\n\n* Decorate a function to be your programs starting point.\n* Generate command line parser based on function signature.\n* Search system environment for option default values.\n\n|pypi_version| |build_status| |coverage|\n\n-----------\nWhy begins?\n-----------\n\nI write a lot of\nsmall programs in `Python`_.\nThese programs often\naccept a small number of\nsimple command line arguments.\nHaving to write\ncommand line parsing code\nin each of these\nsmall programs both\nbreaks my train of thought\nand greatly increases the\nvolume of code I am writting.\n\nBegins was implemented to\nremove the boilerplate code\nfrom these Python programs.\nIt's not intended to replace\nthe rich command line processing\nneeded for larger applications.\n\n------------\nRequirements\n------------\n\nFor Python versions earlier\nthan Python 3.3,\nthe `funcsigs`_ package from the\n`Python Package Index`_ is\nrequired.\n\nFor Python version 2.6,\nthe `argparse`_ package from the\n`Python Package Index`_ is\nalso required.\n\nBoth of these dependencies are\nlisted in the package configuration.\nIf using `Pip`_ to\ninstall *begins* then\nthe required dependencies will\nbe automatically installed.\n\n------------\nInstallation\n------------\n\n*begins* is available\nfor download from\nthe `Python Package Index`_.\nTo install using `Pip`_ ::\n\n$ pip install begins\n\nAlternatively, the latest\ndevelopment version can be\ninstalled directly\nfrom `Github`_. ::\n\n$ pip install git+https://github.com/aliles/begins.git\n\nPlease note that\n*begins* is still in\nan alpha state \nand therefore\nthe API or behaviour\ncould change.\n\n---------------------------------\nSetting a programs starting point\n---------------------------------\n\nThe ``begin.start()`` function can be\nused as a function call\nor a decorator.\nIf called as a function\nit returns ``True`` when\ncalled from the ``__main__`` module.\nTo do this it inspects\nthe stack frame of the caller,\nchecking the ``__name__`` global.\n\nThis allows the following Python pattern::\n\n >>> if __name__ == '__main__':\n ... pass\n\nTo be replace with::\n\n >>> import begin\n >>> if begin.start():\n ... pass\n\nIf used as a decorator\nto annotate a function\nthe function will be called\nif defined in the ``__main__`` module\nas determined by inspecting\nthe current stack frame.\nAny definitions that follow\nthe decorated function\nwont be created until\nafter the function call\nis complete.\n\nUsage of ``begin.start()`` as\na decorator looks like::\n\n >>> import begin\n >>> @begin.start\n ... def run():\n ... pass\n\nBy deferring the execution\nof the function until after\nthe remainder of the module has loaded\nensures the main function doesn't fail\nif depending on something\ndefined in later code.\n\n----------------------------\nParsing command line options\n----------------------------\n\nIf ``begin.start()`` decorates a\nfunction accepts parameters\n``begin.start()`` will\nprocess the command for\noptions to pass as\nthose parameters::\n\n >>> import begin\n >>> @begin.start\n ... def run(name='Arther', quest='Holy Grail', colour='blue', *knights):\n ... \"tis but a scratch!\"\n\nThe decorated function above\nwill generate the following\ncommand line help::\n\n usage: example.py [-h] [-n NAME] [-q QUEST] [-c COLOUR]\n [knights [knights ...]]\n\n tis but a scratch!\n\n positional arguments:\n knights\n\n optional arguments:\n -h, --help show this help message and exit\n -n NAME, --name NAME (default: Arther)\n -q QUEST, --quest QUEST\n (default: Holy Grail)\n -c COLOUR, --colour COLOUR\n (default: blue)\n\nIn Python3, any `function annotations`_\nfor a parameter become\nthe command line option help.\nFor example::\n\n >>> import begin\n >>> @begin.start # doctest: +SKIP\n ... def run(name: 'What, is your name?',\n ... quest: 'What, is your quest?',\n ... colour: 'What, is your favourite colour?'):\n ... pass\n\nWill generate command help like::\n\n usage: holygrail_py3.py [-h] -n NAME -q QUEST -c COLOUR\n\n optional arguments:\n -h, --help show this help message and exit\n -n NAME, --name NAME What, is your name?\n -q QUEST, --quest QUEST\n What, is your quest?\n -c COLOUR, --colour COLOUR\n What, is your favourite colour?\n\nCommand line parsing supports:\n\n* positional arguments\n* keyword arguments\n* default values\n* variable length arguments\n* annotations\n\nCommand line parsing\ndoes not support\nvariable length keyword arguments,\ncommonly written as\n``**kwargs``.\nIf variable length keyword arguments\nare used by\nthe decorated function\nan exception\nwill be raised.\n\nIf a parameter\ndoes not have a default,\nfailing to pass a value\non the command line\nwill cause running the program to\nprint an error and exit.\n\nFor programs that have\na large number of options\nit may be preferable to\nonly use long options.\nTo suppress short options,\npass ``False`` as the\n``short_args`` keyword argument to\nthe ``begin.start`` decorator::\n\n >>> import begin\n >>> @begin.start(short_args=False)\n ... def run(name='Arther', quest='Holy Grail', colour='blue', *knights):\n ... \"tis but a scratch!\"\n\nThis program will not\naccept ``-n``, ``-q`` or ``-c``\nas option names.\n\nSimilarity, a large number of\ncommand line options may\nbe better displayed in\nalphabetical order.\nThis can be achieved\nby passing ``lexical_order``\nas ``True``::\n\n >>> import begin\n >>> @begin.start(lexical_order=True)\n ... def main(charlie=3, alpha=1, beta=2):\n ... pass\n\nThis program will list\nthe command line options as\n``alpha``, ``beta``, ``charlie``\ninstead of the order\nin which the function\naccepts them.\n\n---------------\nFurther Reading\n---------------\n\nA walk-through tutorial,\nthe remainder of this guide\nand API documentation can\nare all part of the\nofficial *begins* documentation\nhosted on `Read The Docs`_.\n\n------\nIssues\n------\n\nAny bug reports or\nfeature requests can\nbe made using GitHub' `issues system`_.\n\n.. _Github: https://github.com/aliles/begins\n.. _Read The Docs: http://begins.readthedocs.org\n.. _Python: http://python.org\n.. _Python Package Index: https://pypi.python.org/pypi\n.. _Pip: http://www.pip-installer.org\n.. _argparse: https://pypi.python.org/pypi/argparse\n.. _issues system: https://github.com/aliles/begins/issues\n.. _funcsigs: https://pypi.python.org/pypi/funcsigs\n.. _function annotations: http://www.python.org/dev/peps/pep-3107/\n\n.. |build_status| image:: https://secure.travis-ci.org/aliles/begins.png?branch=master\n :target: https://travis-ci.org/aliles/begins\n :alt: Current build status\n\n.. |coverage| image:: https://coveralls.io/repos/aliles/begins/badge.png?branch=master\n :target: https://coveralls.io/r/aliles/begins?branch=master\n :alt: Latest PyPI version\n\n.. |pypi_version| image:: https://pypip.in/v/begins/badge.png\n :target: https://crate.io/packages/begins/\n :alt: Latest PyPI version", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://begins.readthedocs.org", "keywords": null, "license": "ASL", "maintainer": null, "maintainer_email": null, "name": "begins", "package_url": "https://pypi.org/project/begins/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/begins/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://begins.readthedocs.org" }, "release_url": "https://pypi.org/project/begins/0.9/", "requires_dist": null, "requires_python": null, "summary": "Command line programs for busy developers", "version": "0.9" }, "last_serial": 1177341, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "aefb6bcf1bb22e4374699fb5c382db38", "sha256": "1ebf1a601118d251d50f84e134bd712d9fd26a1a744fd80ba5626a1fa9101011" }, "downloads": -1, "filename": "begins-0.1.tar.gz", "has_sig": false, "md5_digest": "aefb6bcf1bb22e4374699fb5c382db38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22895, "upload_time": "2013-06-24T11:38:15", "url": "https://files.pythonhosted.org/packages/a3/c6/b110d525b1deeb9905ff0638e8d23711ee12b6859d3632ab36099818e72e/begins-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "8a37383fdb539fc7f6ddd5f00ef2e78e", "sha256": "be46446d163eeeb11773315eaddc54f7a453731a15d0460dada2999fb0e4abe2" }, "downloads": -1, "filename": "begins-0.2.tar.gz", "has_sig": false, "md5_digest": "8a37383fdb539fc7f6ddd5f00ef2e78e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32281, "upload_time": "2013-07-04T11:51:20", "url": "https://files.pythonhosted.org/packages/4b/ae/9c7e49ffcfe4913bd78f64d95b03f567092bdc20109575fa43eb549c9c84/begins-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "a9adf67f7220c874592d3a28eef89aab", "sha256": "b09597007b123b1b460a3da3638b9a3d45dead5c041c4370215f7cfef415d464" }, "downloads": -1, "filename": "begins-0.3.tar.gz", "has_sig": false, "md5_digest": "a9adf67f7220c874592d3a28eef89aab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18945, "upload_time": "2013-07-10T03:16:24", "url": "https://files.pythonhosted.org/packages/3a/51/79d8b6d40f70df81ac6bad9c401e030968ec8a75108738d19992bfa9c65b/begins-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "2448e2df365e4143e124d0ca9b5e5d79", "sha256": "e1da001a5d8102e61c5b1fd0e8f25e3218d77e15e56fe60f93d63d5ce690604c" }, "downloads": -1, "filename": "begins-0.4.tar.gz", "has_sig": false, "md5_digest": "2448e2df365e4143e124d0ca9b5e5d79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25814, "upload_time": "2013-07-20T12:02:35", "url": "https://files.pythonhosted.org/packages/ab/78/b2bb8eee8c623da878bbe0fdae8ab0e470e3ee0358246dafe31351956099/begins-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "0d45d018a765cfb187a5d68c5ec24559", "sha256": "95f993338e99a41c10aedc4b63d862e9fb601b88be0442cdb96b30c282330d03" }, "downloads": -1, "filename": "begins-0.5.tar.gz", "has_sig": false, "md5_digest": "0d45d018a765cfb187a5d68c5ec24559", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28694, "upload_time": "2013-08-01T12:03:24", "url": "https://files.pythonhosted.org/packages/72/d4/63388f528d8e23a73928dff0df01c6d4a278e823aaf38f74289c3c5c295e/begins-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "848fb715cd924728fadbba509f604b13", "sha256": "878063556a497552bb843405d98140ce2cfa418cc775260009089d435e9b90ad" }, "downloads": -1, "filename": "begins-0.6.tar.gz", "has_sig": false, "md5_digest": "848fb715cd924728fadbba509f604b13", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30323, "upload_time": "2013-08-27T12:20:02", "url": "https://files.pythonhosted.org/packages/5e/8e/2bd14697c30b948c391616dcd8c2a3c026edbf0f5bc5240bd6d6de8629d8/begins-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "f85d2814082d19b48362de8a638978c9", "sha256": "c345946f82b9135572646531ba84bc6dc776992ffdb081e72422e421a21b0a70" }, "downloads": -1, "filename": "begins-0.7.tar.gz", "has_sig": true, "md5_digest": "f85d2814082d19b48362de8a638978c9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34605, "upload_time": "2013-10-01T13:03:39", "url": "https://files.pythonhosted.org/packages/91/77/1b8c218a213c096c04f9f152da8d2e2974ca1747ff09b351500b0c059e99/begins-0.7.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "4d7c7179bafcd968fd74c43ef66f32e3", "sha256": "17a4349cc5b1e05fd9316b49ed2064f0bfcd5762c3b6d6694a9521394407c2f8" }, "downloads": -1, "filename": "begins-0.7.1.tar.gz", "has_sig": false, "md5_digest": "4d7c7179bafcd968fd74c43ef66f32e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34744, "upload_time": "2013-10-03T12:00:00", "url": "https://files.pythonhosted.org/packages/f5/d0/682d49ae0aaaf520160c75dbbeac5deb60af25212735d99ddba0b9c832f4/begins-0.7.1.tar.gz" } ], "0.8": [ { "comment_text": "", "digests": { "md5": "003fc08252913d0ef076e9461b8bafef", "sha256": "7de0dccbb2b6f32e361717f5971bb9c227137763711dd739625722d06c55da39" }, "downloads": -1, "filename": "begins-0.8-py27-none-any.whl", "has_sig": false, "md5_digest": "003fc08252913d0ef076e9461b8bafef", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 26994, "upload_time": "2014-03-13T12:17:38", "url": "https://files.pythonhosted.org/packages/38/e5/577c6a0a1a99fcc9dc90fe76cfdf87d77c4d4a091a6202533349b78ad66d/begins-0.8-py27-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3ff782d00c0069178a6543a3869258a2", "sha256": "625b688cbb62d89f11f44a1579257581947e02f4657834aa55c1d89de06f6b90" }, "downloads": -1, "filename": "begins-0.8.tar.gz", "has_sig": false, "md5_digest": "3ff782d00c0069178a6543a3869258a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 639854, "upload_time": "2014-03-13T12:17:31", "url": "https://files.pythonhosted.org/packages/11/09/175974ae43d6dd2858f3b5d6a360ba6cc20aa1b9c1b8a18149f3712d4299/begins-0.8.tar.gz" } ], "0.9": [ { "comment_text": "", "digests": { "md5": "ba201b473d587d0bc58b147dc63eaf2c", "sha256": "1aebcdc04a36d64d6462f38fc0ece62fa1b96262db5a7a680eec782b75ceee66" }, "downloads": -1, "filename": "begins-0.9-py2-none-any.whl", "has_sig": false, "md5_digest": "ba201b473d587d0bc58b147dc63eaf2c", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 27155, "upload_time": "2014-08-02T01:58:50", "url": "https://files.pythonhosted.org/packages/ea/cf/6082c84e98e130e60df7d7bfe4bbb2cf020da230428554bab6e2d1469f34/begins-0.9-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0c05924c76f37f7499f1f3306d374aa8", "sha256": "98864dc7593ce438074ed30e4c030dcb37e795376726d9150d557ed9d868ef55" }, "downloads": -1, "filename": "begins-0.9.tar.gz", "has_sig": false, "md5_digest": "0c05924c76f37f7499f1f3306d374aa8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 678194, "upload_time": "2014-08-02T01:58:46", "url": "https://files.pythonhosted.org/packages/27/38/21f90d519e4c71df5826436c367c3ae980275655b3c9b5538f02545f6b69/begins-0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ba201b473d587d0bc58b147dc63eaf2c", "sha256": "1aebcdc04a36d64d6462f38fc0ece62fa1b96262db5a7a680eec782b75ceee66" }, "downloads": -1, "filename": "begins-0.9-py2-none-any.whl", "has_sig": false, "md5_digest": "ba201b473d587d0bc58b147dc63eaf2c", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 27155, "upload_time": "2014-08-02T01:58:50", "url": "https://files.pythonhosted.org/packages/ea/cf/6082c84e98e130e60df7d7bfe4bbb2cf020da230428554bab6e2d1469f34/begins-0.9-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0c05924c76f37f7499f1f3306d374aa8", "sha256": "98864dc7593ce438074ed30e4c030dcb37e795376726d9150d557ed9d868ef55" }, "downloads": -1, "filename": "begins-0.9.tar.gz", "has_sig": false, "md5_digest": "0c05924c76f37f7499f1f3306d374aa8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 678194, "upload_time": "2014-08-02T01:58:46", "url": "https://files.pythonhosted.org/packages/27/38/21f90d519e4c71df5826436c367c3ae980275655b3c9b5538f02545f6b69/begins-0.9.tar.gz" } ] }