{ "info": { "author": "Julien Tayon", "author_email": "julien@tayon.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Python Software Foundation License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.2" ], "description": "=======================\ncheck_arg documentation\n=======================\n\n* source: https://github.com/jul/check_arg\n* ticketing: https://github.com/jul/check_arg/issues\n\n.. image:: \n https://travis-ci.org/jul/check_arg.png\n\nUsage\n=====\n\n\nChecking optional/positional arguments and auto documenting at the same time\n\n.. warning::\n The documentation relies on your talent for naming your functions, and having sensible names.\n\nExample by using some currying, the purpose is to achieve auto documentation\nand validation so that::\n\n >>> @set_default_kw_value(port=1026,nawak=123)\n >>> @must_have_key(\"name\")\n >>> @min_positional(2)\n >>> @validate(name = naming_convention(), port = in_range(1024,1030 ))\n >>> def toto(*a,**kw):\n ... \"\"\"useless fonction\"\"\"\n ... print a\n ... print kw\n ... print \"done\"\n ... return 1\n\ngives this results::\n\n >>> help(toto)\n ... Help on function toto in module __main__:\n ... \n ... toto(*a, **kw)\n ... useless fonction\n ... \n ... **kewords must validate the following rules**:\n ... \n ... * key: must belong to [ 1024, 1030 [,\n ... * key: must begin with underscore\n ... \n ... **at_least_n_positional** :2\n ... \n ... \n ... **keyword_must_contain_key** :name\n ... \n ... \n ... **default_kw_value** :\n ... \n ... * params: port is 1026,\n ... * params: nawak is 123\n\nUse\n===\n\nTo create a decorator that will be called *before* the called functions and which \nnames and arguments will enhance the documentation as in the following example just do::\n\n >>> set_default_kw_value = valid_and_doc(default_kw_value)\n >>> min_positional = valid_and_doc(at_least_n_positional)\n\n\n\nYou can provide a default template for the documention as a second argument::\n >>> def in_range(low,high):\n ... def _in_range(_int):\n ... return high >= _int > low\n ... _in_range.__doc__ = \"\"\"belong to [ %s, %s [\"\"\" % (low, high)\n ... return _in_range\n\n >>> def _validate(**validator):\n ... def wrap(**validator):\n ... def rewrapped(*a,**kw):\n ... for key,valid in validator.items():\n ... if key in kw and not valid(kw[key]):\n ... raise Exception(\n ... \"Key <%s> does not match rule %s\" % (\n ... key,default_doc_maker(\n ... valid,**{ key: kw[key]}\n ... ) ) )\n ... return rewrapped\n ...\n >>> def validate_doc(_validate, **validator):\n ... return \"\"\"\n ...\n ... **kewords must validate the following rules**:\n ...\n ... %s\n ... \"\"\" % ( \",\\n\".join(\n ... \"* key: <%s> must %s\" % (\n ... key, valid.__doc__ is not None and valid.__doc__ or valid.__name__\n ... ) for key, valid in validator.items()\n ... ) )\n ... return [ wrap, validate_doc ]\n ... \n >>> validate = valid_and_doc(*_validate())\n\nChangelog\n=========\n\n* 0.1.0 initial release\n* 0.1.(1|2|3) trying to have README.txt being seen as 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.org/jul/check_arg", "keywords": null, "license": "License :: OSI Approved :: BSD License", "maintainer": null, "maintainer_email": null, "name": "check_arg", "package_url": "https://pypi.org/project/check_arg/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/check_arg/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.org/jul/check_arg" }, "release_url": "https://pypi.org/project/check_arg/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "wrapping decorator to enhance the documentation", "version": "0.1.3" }, "last_serial": 1511526, "releases": { "0.1.3": [ { "comment_text": "", "digests": { "md5": "57563050f29e722ea565780a8c4bee87", "sha256": "905b1cf3c8b14c3a7a1f3154c3bc5b8191bb280d5193d122b688b6efecb7dcd5" }, "downloads": -1, "filename": "check_arg-0.1.3.tar.gz", "has_sig": false, "md5_digest": "57563050f29e722ea565780a8c4bee87", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4382, "upload_time": "2012-12-16T00:37:39", "url": "https://files.pythonhosted.org/packages/df/89/0d492e67b7a4d7a7f6097e4524adec987da8d5ed3f0ab7459e688f92d8e9/check_arg-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "57563050f29e722ea565780a8c4bee87", "sha256": "905b1cf3c8b14c3a7a1f3154c3bc5b8191bb280d5193d122b688b6efecb7dcd5" }, "downloads": -1, "filename": "check_arg-0.1.3.tar.gz", "has_sig": false, "md5_digest": "57563050f29e722ea565780a8c4bee87", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4382, "upload_time": "2012-12-16T00:37:39", "url": "https://files.pythonhosted.org/packages/df/89/0d492e67b7a4d7a7f6097e4524adec987da8d5ed3f0ab7459e688f92d8e9/check_arg-0.1.3.tar.gz" } ] }