{ "info": { "author": "Daniel Mueller", "author_email": "deso@posteo.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: User Interfaces", "Topic :: System :: Shells" ], "description": "argcomp\n=======\n\nPurpose\n-------\n\nThe **argcomp** package provides automatic argument completion support\nfor all Python programs that use argparse's ArgumentParser class for\ntheir parameter handling. It does so by providing a drop-in replacement\nthat transparently provides a (hidden) --\\_complete argument that can be\ninvoked to automatically complete arguments. All that has to be done to\nhook it up is to register a completion by invocation of the program with\nthis argument with the shell.\n\nRationale\n---------\n\nThere already exist a couple of packages that provide similar\nfunctionality. However, each was identified as inadequate.\n\n- *optcomplete*: The *optcomplete* package, as the name suggests, only\n works with the optparse module which is deprecated and should not be\n used in new programs. It is also incompatible with Python 3,\n disqualifying it immediately.\n\n- *python-selfcompletion*: This package works with argparse but is also\n not Python 3 ready. The code is not very well structured and\n inflexible because support for custom completer functions is missing.\n\n- *argcomplete*: The argcomplete package appears to be Python 3\n compatible. However, in order to provide its functionality it copies,\n pastes, and modifies the argparse code as well as the shlex module.\n This approach comes with the downside of requiring backports of fixes\n to those packages. Not speaking of it plainly being ugly. On the\n bright side, this package supports custom completers and is the only\n viable option but because of the code duplication it was discarded as\n well.\n\n**argcomp** combines the best of the aforementioned packages. It is\nfully Python 3 compliant. It interfaces with argparse's ArgumentParser\nwithout duplicating all its code and without peeking into any internals.\nLastly, it provides support for custom completers to allow for context\nsensitive completions.\n\nUsage\n-----\n\nTo make use of the **argcomp** package, the user only needs to replace\nthe usage of *argparse*'s ``ArgumentParser`` with the provided\n``CompletingArgumentParser`` class. Because the latter is fully\ncompatible to the former no additional work is required.\n\n.. code:: diff\n\n --- example.py\n +++ example.py\n @@ -1,7 +1,7 @@\n #!/usr/bin/python\n\n -from argparse import (\n - ArgumentParser,\n +from deso.argcomp import (\n + CompletingArgumentParser as ArgumentParser,\n )\n\n parser = ArgumentParser(description=\"Process some integers.\")\n\nIn order to make the completion functionality accessible from the shell,\nit needs to be registered first. Typically, this registration happens by\nsourcing a prepared completion file upon start of the shell. A sample\ncompletion file (valid for bash) looks like so:\n\n.. code:: bash\n\n _complete_example()\n {\n local completions=$(\"${1}\" --_complete \"${COMP_CWORD}\" \"${COMP_WORDS[@]}\")\n if [ $? -eq 0 ]; then\n readarray -t COMPREPLY < <(echo -n \"${completions}\")\n fi\n }\n\n complete -F _complete_example example.py\n\nHere, the script ``example.py`` is registered to be completed by the\nnewly created shell function ``_complete_example``. Once this file is\nsourced in a shell, completion is available.\n\nCompleters\n----------\n\n**argcomp** supports custom completers. A completer is a simple function\nthat is registered along with the argument for which to provide\ncompletion. Such a function needs to have a given interface and yield\nits completions. Other than that there are practically no limitations on\nwhat a completer can use to provide completions.\n\nA sample completer providing completions for local files and directories\ncan look like this:\n\n.. code:: python\n\n def localFileCompleter(parser, values, word):\n \"\"\"A completer for files in the current working directory.\"\"\"\n for value in listdir():\n if value.startswith(word):\n yield value\n\nRegistration is trivial and happens along with argument specification:\n\n.. code:: diff\n\n --- cat.py\n +++ cat.py\n @@ -13,7 +13,7 @@ def localFileCompleter(parser, values, word):\n\n parser = CompletingArgumentParser(prog=\"cat\")\n parser.add_argument(\n - \"files\", nargs=\"+\",\n + \"files\", nargs=\"+\", completer=localFileCompleter,\n help=\"Files to cat.\"\n )\n\nNote that completers are not part of *argparse*'s ArgumentParser. As\nsuch, switching back to it requires removal of the completer keyword\nparameter.\n\nInstallation\n------------\n\nThe **argcomp** package has no dependencies other than a standard Python\n3 installation. In order to install it it suffices to make the src/\ndirectory known to Python by embedding it into the ``PYTHONPATH``.\n\nIf you are using `Gentoo Linux `__, there is an\n`ebuild `__ available that\ncan be used directly.\n\nSupport\n-------\n\nThe module is tested with Python 3. There is no work going on to ensure\ncompatibility with Python 2.", "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/d-e-s-o/argcomp", "keywords": "argcomp argparse ArgumentParser shell completion", "license": "GPLv3", "maintainer": null, "maintainer_email": null, "name": "argcompd", "package_url": "https://pypi.org/project/argcompd/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/argcompd/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/d-e-s-o/argcomp" }, "release_url": "https://pypi.org/project/argcompd/0.9.0.1/", "requires_dist": null, "requires_python": null, "summary": "A package providing automated shell completion support for argparse.", "version": "0.9.0.1" }, "last_serial": 2593066, "releases": { "0.9.0.0": [ { "comment_text": "", "digests": { "md5": "9b512e2d06b837c0e67105fa68da7214", "sha256": "2e22095d64e9ce9884f03c7aa2c714b2b00dfb170c1de5bb16142c300963c71e" }, "downloads": -1, "filename": "argcompd-0.9.0.0.tar.gz", "has_sig": true, "md5_digest": "9b512e2d06b837c0e67105fa68da7214", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28875, "upload_time": "2017-01-23T15:44:46", "url": "https://files.pythonhosted.org/packages/28/84/0c8b7faaec816ab0a9b574366495300ffd72a8fab8d668e018619a40dec3/argcompd-0.9.0.0.tar.gz" } ], "0.9.0.1": [ { "comment_text": "", "digests": { "md5": "36fb48190077e94262fed91dc411f0dd", "sha256": "fbd5fb432dbb89da52cefd0b584f29d333127b6f402650ecbf13c76c5d56c17a" }, "downloads": -1, "filename": "argcompd-0.9.0.1.tar.gz", "has_sig": true, "md5_digest": "36fb48190077e94262fed91dc411f0dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28862, "upload_time": "2017-01-23T15:59:53", "url": "https://files.pythonhosted.org/packages/20/a1/98da1a245f025e5ede8cf477ff63e5db0bad49d8d066dcad80f419f20906/argcompd-0.9.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "36fb48190077e94262fed91dc411f0dd", "sha256": "fbd5fb432dbb89da52cefd0b584f29d333127b6f402650ecbf13c76c5d56c17a" }, "downloads": -1, "filename": "argcompd-0.9.0.1.tar.gz", "has_sig": true, "md5_digest": "36fb48190077e94262fed91dc411f0dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28862, "upload_time": "2017-01-23T15:59:53", "url": "https://files.pythonhosted.org/packages/20/a1/98da1a245f025e5ede8cf477ff63e5db0bad49d8d066dcad80f419f20906/argcompd-0.9.0.1.tar.gz" } ] }