{ "info": { "author": "Aleksandr Rudakov", "author_email": "ribozz@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "***********************\nAlternatives api\n***********************\n\nAlternatives basics\n---------------------\n\nAlternatives api is just a syntax sugar for selecting alternative variants from some set of values.\nThe main thing is alternative class that implements late call on callbacks.\nThis allow to apply boolean logic on callbacks without being executed::\n\n a1 = Alternative(lambda: a)\n b1 = Alternative(lambda: b)\n\n a_b = a1 | b1\n assert isinstance(a_b, Alternative)\n assert bool(a_b) is (a or b)\n\nAlso you can note, in the example above, that alternative can provide python truth when it's needed by\ncalling callbacks and evaluating boolean expressions.\n\nAlternatives usage\n---------------------\n\nHow it may be used::\n\n package(one_of({\n os_centos() or os_windows(): 'php',\n os_ubuntu(): 'php5'\n }))\n\n\nHere one of values will be selected: php or php5.\n\nAlternative is object, that's why we can use it as dictionary key.\n\nIn the example above you can see one_of() method:\n\n.. automodule:: pywizard.api\n :members: one_of\n :imported-members:\n\nAnother style of evaluating alternatives is all_of:\n\n.. automodule:: pywizard.api\n :members: all_of\n :imported-members:\n\nAnd nobody restrict you from creating your own alternatives selection style.\nUse source of one_of, all_of as reference.\n\nChecks declaration\n-----------------------------\n\n*Check* is just a python function that return boolen with added annotation on it::\n\n @alternative\n def os_linux():\n \"\"\"\n os_linux()\n Checks if it is linux-like os.\n \"\"\"\n info = os_info()\n return 'linux' in info['platform']\n\n.. note::\n As function is annotated there is some extra work needed to provide correct documentation for this function.\n @alternative handles copying __doc__ transparently for your function. But, you should take care\n of specifying correct method signature in first line of docstring.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "alternatives", "package_url": "https://pypi.org/project/alternatives/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/alternatives/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/alternatives/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Alternatives api is just a syntax sugar for selecting alternative variants from some set of values", "version": "0.1.0" }, "last_serial": 937963, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "ce8d73e29db2549ae45d662c1fe3f913", "sha256": "a27fbe2487fcf16feb4f54d4a94bfaf656d8ec2eef48f0d87608fe8b5aa490e8" }, "downloads": -1, "filename": "alternatives-0.1.0.zip", "has_sig": false, "md5_digest": "ce8d73e29db2549ae45d662c1fe3f913", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4992, "upload_time": "2013-12-06T22:46:40", "url": "https://files.pythonhosted.org/packages/1b/b3/a2c5af3fb67d6f4222aa568575fef345d991f6b4e0d04ce89f29d3001e62/alternatives-0.1.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ce8d73e29db2549ae45d662c1fe3f913", "sha256": "a27fbe2487fcf16feb4f54d4a94bfaf656d8ec2eef48f0d87608fe8b5aa490e8" }, "downloads": -1, "filename": "alternatives-0.1.0.zip", "has_sig": false, "md5_digest": "ce8d73e29db2549ae45d662c1fe3f913", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4992, "upload_time": "2013-12-06T22:46:40", "url": "https://files.pythonhosted.org/packages/1b/b3/a2c5af3fb67d6f4222aa568575fef345d991f6b4e0d04ce89f29d3001e62/alternatives-0.1.0.zip" } ] }