{ "info": { "author": "Jason Graffius", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: User Interfaces", "Topic :: Utilities" ], "description": "Pymain\n======\n\nPymain - Simplified main\n\nPymain is a decorator and related tools to simplify your ``main`` function(s).\nIt is intended to be more simple to use and understand than ``argparse``, while\nstill providing most of the functionality of similar libraries.\n\nDescription\n-----------\n\nThe basic idea of ``pymain`` is that your main function (though it doesn't need\nto be called \"main\"), and therefore your script or application itself, probably\ntakes parameters and keyword arguments in the form of command line arguments.\nSince that interface works very similar to calling a python function, ``pymain``\ntranslates between those interfaces for you. In addition, so many scripts with\nentry points include the ``if __name__ == '__main__':`` boilerplate, and pymain\naims to eliminate that.\n\nUsage\n-----\n\nImport and use the ``@pymain`` decorator before your main function that has type\nannotations for the parameters. If you don't need any short options or aliases,\nthat is all you need to do. Pymain will detect whether the defining module is\nrun as a script (and therefore ``__name__ == \"__main__\"``) or if it is being\nimported. If it is run as a script, then main will be called and given arguments\nbased on ``sys.argv``. If it is imported, then pymain will not run the function\nas a main function and it can still be called normally.\n\nPymain uses the type annotations to determine what types to expect. For short\noptions or aliases, you can add an ``@alias`` decorator after the ``@pymain``\ndecorator describing the alias (either a single alias or a dictionary of\nmultiple)\n\nAll arguments that are greater than one character in length are long options\n(e.g. --arg), and arguments that have a single character are short options\n(e.g. -a). Aliases follow the same rules.\n\nExamples\n--------\n\noptional.py:\n\n.. code:: python\n\n from pymain import pymain\n\n @pymain\n def main(a: float, b: float, c: str = None):\n print(a / b)\n if c is not None:\n print(c)\n\nCommand line:\n\n.. code:: bash\n\n ~ $ python optional.py 4 2\n 2.0\n\n.. code:: bash\n\n ~ $ python optional.py 9 2 message\n 4.5\n message\n\n--------------\n\nkeyword.py:\n\n.. code:: python\n\n from pymain import pymain\n\n @pymain\n def main(first: int, second: int, *, message: str = None):\n print(first + second)\n if message is not None:\n print(message)\n\nCommand line:\n\n.. code:: bash\n\n ~ $ python main.py 4 6\n 10\n\n.. code:: bash\n\n ~ $ python main.py 1 2 --message \"Hello, World!\"\n 3\n Hello, World!\n\n--------------\n\nalias.py:\n\n.. code:: python\n\n from pymain import pymain, alias\n\n @pymain\n @alias({\"opt1\": \"x\", \"opt2\": \"y\"})\n def foo(value: float, *, opt1: float = 1.0, opt2: float = 2.0):\n print(value + opt1)\n print(value - opt2)\n\nCommand line:\n\n.. code:: bash\n\n ~ $ python alias.py 2\n 3.0\n 0.0\n\n.. code:: bash\n\n ~ $ python alias.py 5 -x 1 -y 1\n 6.0\n 4.0\n\n.. code:: bash\n\n ~ $ python alias.py 10 --opt1 5 --opt2 2\n 15.0\n 8.0", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jasongraffius/pymain", "keywords": "main arguments option argparse", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pymain", "package_url": "https://pypi.org/project/pymain/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pymain/", "project_urls": { "Homepage": "https://github.com/jasongraffius/pymain" }, "release_url": "https://pypi.org/project/pymain/0.3.1/", "requires_dist": null, "requires_python": "", "summary": "A simplified interface for your main function.", "version": "0.3.1" }, "last_serial": 2889697, "releases": { "0.1.4": [ { "comment_text": "", "digests": { "md5": "6d7084fc15156baba58abc1c93e0411b", "sha256": "42286eceea110c88d3ea486546b50801c341812f016f93b116b6e91ac4c0962f" }, "downloads": -1, "filename": "pymain-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "6d7084fc15156baba58abc1c93e0411b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5893, "upload_time": "2017-04-15T22:03:48", "url": "https://files.pythonhosted.org/packages/ba/1f/e3911217f4435d0991c47d140845e0cc1e10423e222f797676899fde2f2c/pymain-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "30860fe77417ec7f3bd40433e3b630aa", "sha256": "4dd700083e0f1fe7127ca5d703c514f314b434082233de206e386af3680642c1" }, "downloads": -1, "filename": "pymain-0.1.4.tar.gz", "has_sig": false, "md5_digest": "30860fe77417ec7f3bd40433e3b630aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3555, "upload_time": "2017-04-15T22:03:50", "url": "https://files.pythonhosted.org/packages/a5/17/f8133e4014d14a69ed4654c294820c9d93f578bf5f5ebe294156b5cee783/pymain-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "93b30f4ff59baf8662b608f8be5d76fd", "sha256": "80e9b8ad1e38dc348e06d9d340a77c0b4d58972fde220884a23e608d607f87aa" }, "downloads": -1, "filename": "pymain-0.1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "93b30f4ff59baf8662b608f8be5d76fd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5933, "upload_time": "2017-04-15T23:49:11", "url": "https://files.pythonhosted.org/packages/23/44/d6978f57317ac13fb4facbe9a5a2def29ae73d6626ae6b9717c3bd39969a/pymain-0.1.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "77def639a824419ab1e7edee31db62fc", "sha256": "7be82a90d805e2fc701ccf924f6d0569245d2f1ed58f40128615bb5aab98450a" }, "downloads": -1, "filename": "pymain-0.1.5.tar.gz", "has_sig": false, "md5_digest": "77def639a824419ab1e7edee31db62fc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3828, "upload_time": "2017-04-15T23:49:13", "url": "https://files.pythonhosted.org/packages/c6/4c/85bb72ed0bdde463a2a013e6d485196893525c85ec32721c947e6bd8fa85/pymain-0.1.5.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "ab591975c71daac3a1e9693cd239a14e", "sha256": "ae2aad6456397d13fd7e1d3fa1d0eeca8a8fdbf884dc22e9a2f92ac05ec88aa9" }, "downloads": -1, "filename": "pymain-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ab591975c71daac3a1e9693cd239a14e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6747, "upload_time": "2017-04-16T01:08:16", "url": "https://files.pythonhosted.org/packages/99/4e/3b8c9ca8e7d5486edf80265b99c411df4d814c27b471f95ec96006f8dbbf/pymain-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e79d43ce3b960ff22f337a167aee5c76", "sha256": "420b824f64cd9fc487ae7b0f9a88a13bc3b9342cff041a0a9b2a78d47c106812" }, "downloads": -1, "filename": "pymain-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e79d43ce3b960ff22f337a167aee5c76", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4620, "upload_time": "2017-04-16T01:08:18", "url": "https://files.pythonhosted.org/packages/bd/1e/626130aadeb664f08abe78dbe95f165ed0a66e6ce5d421b77249578c4a06/pymain-0.2.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "836050de98b8be3be1ae8a7358a48770", "sha256": "1a53c3807371ee956b57893df2e2946b251fdf04f6168c182ad17f3bcfcb88a1" }, "downloads": -1, "filename": "pymain-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "836050de98b8be3be1ae8a7358a48770", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7427, "upload_time": "2017-05-22T02:07:20", "url": "https://files.pythonhosted.org/packages/b0/d7/4e6afeca23e24e87279289e1386e4bdf0d2dd8879470d738114877677c77/pymain-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d8cea7f50d6669d9f3731edb08f9c961", "sha256": "956f7549f189d2b6a59684a37e66a7c6e2ad6fb04ed9e44329159af592bf4889" }, "downloads": -1, "filename": "pymain-0.3.1.tar.gz", "has_sig": false, "md5_digest": "d8cea7f50d6669d9f3731edb08f9c961", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5112, "upload_time": "2017-05-22T02:07:22", "url": "https://files.pythonhosted.org/packages/1e/90/56f05ea1855ba1c7bce903111c3e0c54e4f57fa4e87ed6ce9e6b53a9a3b2/pymain-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "836050de98b8be3be1ae8a7358a48770", "sha256": "1a53c3807371ee956b57893df2e2946b251fdf04f6168c182ad17f3bcfcb88a1" }, "downloads": -1, "filename": "pymain-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "836050de98b8be3be1ae8a7358a48770", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7427, "upload_time": "2017-05-22T02:07:20", "url": "https://files.pythonhosted.org/packages/b0/d7/4e6afeca23e24e87279289e1386e4bdf0d2dd8879470d738114877677c77/pymain-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d8cea7f50d6669d9f3731edb08f9c961", "sha256": "956f7549f189d2b6a59684a37e66a7c6e2ad6fb04ed9e44329159af592bf4889" }, "downloads": -1, "filename": "pymain-0.3.1.tar.gz", "has_sig": false, "md5_digest": "d8cea7f50d6669d9f3731edb08f9c961", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5112, "upload_time": "2017-05-22T02:07:22", "url": "https://files.pythonhosted.org/packages/1e/90/56f05ea1855ba1c7bce903111c3e0c54e4f57fa4e87ed6ce9e6b53a9a3b2/pymain-0.3.1.tar.gz" } ] }