{ "info": { "author": "Robin Andeer", "author_email": "robin.andeer@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Plugins", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "docopt-rc\n==========\n**docopt-rc** is a drop-in rc-file parser augmenter for `docopt `_.\n\nQuick User's Guide\n-------------------\nThese are the nessesary steps to use **docopt-rc**:\n\n1. Install the package\n\n.. code-block:: console\n\n $ pip install docopt-rc\n\n2. Import into your project\n\n.. code-block:: python\n\n from docopt import docopt\n import rc\n import myscript\n\n3. Run docopt to parse the command line arguments\n\n.. code-block:: python\n \n args = docopt(__doc__, version='MyScript {v}'.format(v=myscript.__version__))\n\n4. Set up your script level defaults (lowest priority)\n\n.. code-block:: python\n\n defaults = {\n 'url': 'news.layervault.com',\n 'category': 'news',\n 'votes': 0\n }\n\n5. Parse potential config-files, both in user home and in the current directory. Missing files are silently skipped.\n\n.. code-block:: python\n\n # Merge the command line arguments with the defaults and any values\n # found in either global (`$HOME`) or local (this folder) config files.\n options = rc.extend_args(args, __file__, defaults, scopes=['global', 'local'])\n\nThat's it. We have now merged the defaults <= user configs <= command line arguments.\n\n\nDocumentation\n----------------\nFor the time being I will refer you to the somewhat complete inline documentation for each function in the package.\n\n\nBackground & Motivation\n-------------------------\nConfig files can unburden the command line and allow users to set user/project specific defaults. A common practice is to name such files `.rc`, e.g. '.bashrc', '.bowerrc'. The values in such an rc-file should take precedence over script level defaults but be overwritten by command line arguments.\n\nI needed a very simple script that would parse both global (user), local (project), and custom config files and play nice with the excellent docopt package.\n\n\nFlaws & Limitations\n-------------------------\n*docopt*, as great as it is, does come with a few limitations when trying to integrate with a config file parser. My solution has three nagging flaws:\n\n1. Boolean options (flags) become a major issue. There isn't any built in way to flag `False` and `probably won't be `_ either. This means you can't override an options that defaults to `True` from a config file. The current solution is to **avoid flags in favor of `--option=`** where bool is ('yes', 'no', 'true', 'false').\n\n2. *docopt* provides a useful way to set defaults. Problem is that I couldn't find a way to parse those defaults to compare what user supplied and default values. I therefore **require all defaults to be set in a separate `dict`** outside of the docstring.\n\n3. The intuative syntax for ``, `--option`, `command` works great *in-script* but would be awkward as a requirement for user authored config files. Q.E.D.: I require that **no two argument/option/command names be the same**.\n\n\nChecklist\n-----------\n\n1. DOES support YAML and JSON file formats (\"JSON is YAML\")\n2. DOES convert docopt args to simpler versions by removing '--' and '<>'\n3. DO NOT define your own defaults in the document string\n4. DO define defaults in a separate `dict`\n5. DO NOT use boolean arguments (flags) you want to overwrite.\n6. DO use `--option=` where 'bool' is 'yes'/'no' in favor of flags\n7. DO expect config files to be named \".rc\"\n8. DO NOT use multiple types of arguments with the the same name\n\n\nLicense, Authors, Changelog\n-----------------------------\nRead LICENSE, AUTHORS, CHANGELOG.rst", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/robinandeer/pythonrc", "keywords": "", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "docopt-rc", "package_url": "https://pypi.org/project/docopt-rc/", "platform": "any", "project_url": "https://pypi.org/project/docopt-rc/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/robinandeer/pythonrc" }, "release_url": "https://pypi.org/project/docopt-rc/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "docopt-rc is a drop-in rc-file parser augmenter for docopt", "version": "0.0.1" }, "last_serial": 996236, "releases": { "0.0.1": [] }, "urls": [] }