{ "info": { "author": "Matt GdV", "author_email": "matthewgdv@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Programming Language :: Python :: 3.7" ], "description": "Overview\n====================\n\nProvides a `Maybe` class which serves as a pseudo-implementation of null-aware operators in python:\n\n* can be used to avoid common `var if var is not None else handle_none(var)` structures\n* Null-aware item access\n* Null-aware attribute access\n* Null-aware chained method calls\n* Can be combined with most operators\n\nInstallation\n====================\n\nTo install use pip:\n\n $ pip install maybe-else\n\n\nOr clone the repo:\n\n $ git clone https://github.com/matthewgdv/maybe.git\n $ python setup.py install\n\n\nUsage\n====================\n\nThe simplest use-case is to wrap the value in the `Maybe` class and call `Maybe.else_()` with an alternative value. If the initial value was `None`,\nthe alternative value will be returned. Otherwise the original value will be returned.\n\n Maybe(None).else_(\"other\") # \"other\"\n Maybe(\"hi\").else_(\"other\") # \"hi\"\n\nMore complex uses involve chaining item/attribute access and method calls off the initial value.\nIf at any point an `IndexError` (item access), `AttributeError` (attribute access), or `TypeError` (method call) is raised, the alternative value will be returned upon calling `Maybe.else_()`.\nOther exception classes are not caught by `Maybe` (intentionally) and will have be to handled normally.\n\n Maybe(\"hi\").monkeyweasel[3].else_(\"other\") # \"other\"\n Maybe({1: \"1\"})[1].isnumeric().else_(\"other\") # True\n\nMost operators can be used with `Maybe`. Actions involving operators will ignore `TypeError`, but other types of exceptions will have to be handled outside the `Maybe` construct.\n\n (Maybe(8) / 2).else_(\"other\") # 4.0\n (Maybe(\"hi\").upper() + \"!\").else_(\"other\") # \"HI!\"\n (Maybe(None) // 3).else_(\"other\") # \"other\"\n (Maybe(11) % 4).else_(\"other\") # 3\n\nIf None would be returned as a result of operations performed on the `Maybe` object, then None will be returned from `Maybe.else_()`, rather than the alternative value.\nThis is because `None` is a legitimate output value, so long as it was not the original input value.\n\n Maybe({1: \"1\"}).get(2).else_(\"other\") # None\n\nThe `Maybe` class will be truthy whenever it would return what it is currently holding on calling `Maybe.else_()`, and will be falsy when it would return the alternative.\n\nContributing\n====================\n\nContributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.\n\nYou can contribute in many ways:\n\nReport Bugs\n--------------------\n\nReport bugs at https://github.com/matthewgdv/maybe/issues\n\nIf you are reporting a bug, please include:\n\n* Your operating system name and version.\n* Any details about your local setup that might be helpful in troubleshooting.\n* Detailed steps to reproduce the bug.\n\nFix Bugs\n--------------------\n\nLook through the GitHub issues for bugs. Anything tagged with \"bug\" and \"help wanted\" is open to whoever wants to implement a fix for it.\n\nImplement Features\n--------------------\n\nLook through the GitHub issues for features. Anything tagged with \"enhancement\" and \"help wanted\" is open to whoever wants to implement it.\n\nWrite Documentation\n--------------------\n\nThe repository could always use more documentation, whether as part of the official docs, in docstrings, or even on the web in blog posts, articles, and such.\n\nSubmit Feedback\n--------------------\n\nThe best way to send feedback is to file an issue at https://github.com/matthewgdv/maybe/issues.\n\nIf you are proposing a new feature:\n\n* Explain in detail how it would work.\n* Keep the scope as narrow as possible, to make it easier to implement.\n* Remember that this is a volunteer-driven project, and that contributions are welcome :)\n\nGet Started!\n--------------------\n\nBefore you submit a pull request, check that it meets these guidelines:\n\n1. If the pull request adds functionality, it should include tests and the docs should be updated. Write docstrings for any functions that are part of the external API, and add\n the feature to the README.md.\n\n2. If the pull request fixes a bug, tests should be added proving that the bug has been fixed. However, no update to the docs is necessary for bugfixes.\n\n3. The pull request should work for the newest version of Python (currently 3.7). Older versions may incidentally work, but are not officially supported.\n\n4. Inline type hints should be used, with an emphasis on ensuring that introspection and autocompletion tools such as Jedi are able to understand the code wherever possible.\n\n5. PEP8 guidelines should be followed where possible, but deviations from it where it makes sense and improves legibility are encouraged. The following PEP8 error codes can be\n safely ignored: E121, E123, E126, E226, E24, E704, W503\n\n6. This repository intentionally disallows the PEP8 79-character limit. Therefore, any contributions adhering to this convention will be rejected. As a rule of thumb you should\n endeavor to stay under 200 characters except where going over preserves alignment, or where the line is mostly non-algorythmic code, such as extremely long strings or function\n calls.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/matthewgdv/maybe", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "maybe-else", "package_url": "https://pypi.org/project/maybe-else/", "platform": "", "project_url": "https://pypi.org/project/maybe-else/", "project_urls": { "Homepage": "https://github.com/matthewgdv/maybe" }, "release_url": "https://pypi.org/project/maybe-else/0.0.5/", "requires_dist": null, "requires_python": "", "summary": "Provides a Maybe class as a Python implementation of null-aware operators.", "version": "0.0.5" }, "last_serial": 5765636, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "4e50978217211384fdd25443e1276403", "sha256": "7c40c1f4aba18442fdf1bf63f69e999a4cf021242f7c107b15d20e9ecdda4a3d" }, "downloads": -1, "filename": "maybe_else-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4e50978217211384fdd25443e1276403", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 3205, "upload_time": "2019-06-15T18:33:08", "url": "https://files.pythonhosted.org/packages/a4/0d/cc12c97bc68ccb7f7bc347caf59373585b300ea1686473f75d6924270d70/maybe_else-0.0.1-py2.py3-none-any.whl" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "15c889f356be077d12f66ba22b2d7434", "sha256": "626bc7a387f08932adbabc3fbef44f7b8bf1a6353d905d15c96290a01a37f093" }, "downloads": -1, "filename": "maybe_else-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "15c889f356be077d12f66ba22b2d7434", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 3206, "upload_time": "2019-06-15T18:37:17", "url": "https://files.pythonhosted.org/packages/6d/04/fa309d160401cb217ad2714b57cbd9488a8822e80251c3f09a976bcac7b1/maybe_else-0.0.2-py2.py3-none-any.whl" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "0a763f6f1111c1e8fe267777705b9d70", "sha256": "97c8fc61ed762055ad651cb25e391f3e4042dd8b3b2a9e7ef0642350d13fa9a3" }, "downloads": -1, "filename": "maybe_else-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "0a763f6f1111c1e8fe267777705b9d70", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5010, "upload_time": "2019-06-15T19:35:31", "url": "https://files.pythonhosted.org/packages/02/35/b3504c562e74f04a095c33d4b4aa10ae86a5552da19fc0bc1b6561d16afc/maybe_else-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dc625112845cc9b83cde30259da9c91f", "sha256": "37a7c0768798d32f13f94a09b988ec97b9d991301b9b0a3857167d9c78c34205" }, "downloads": -1, "filename": "maybe-else-0.0.3.tar.gz", "has_sig": false, "md5_digest": "dc625112845cc9b83cde30259da9c91f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4239, "upload_time": "2019-06-15T19:35:33", "url": "https://files.pythonhosted.org/packages/de/33/a36231d1a9f821a3658a343e9d0ddbadbf855e0be38e6a78226f9eabc8ed/maybe-else-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "cacbe433831c554d31a39c6f6a68a2ff", "sha256": "da905157e599267d8f861f651978c0714e2fdab77c65f4b76e520d7fb138cc1a" }, "downloads": -1, "filename": "maybe-else-0.0.4.tar.gz", "has_sig": false, "md5_digest": "cacbe433831c554d31a39c6f6a68a2ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4508, "upload_time": "2019-07-15T21:15:35", "url": "https://files.pythonhosted.org/packages/23/5c/e7af92fbdf5d9628367dde5eb4fb68031812cdce9df2209dea198e084aaf/maybe-else-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "f0db4ac3a222e76023fa67dc2697ee81", "sha256": "5b7ad0fda4ab9801103ebc593415682a7c3e426e8d1f906b759d6eb724fb4813" }, "downloads": -1, "filename": "maybe_else-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "f0db4ac3a222e76023fa67dc2697ee81", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5277, "upload_time": "2019-09-01T00:15:42", "url": "https://files.pythonhosted.org/packages/55/03/31696038c43a3c62d10ba026544aa7122189406173b42f59f25d090455f3/maybe_else-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "993ecbce69fb7d2a237db4b35b394645", "sha256": "743c0e6d912ef016b9facf151cc660c5c096eb70db39c04c45a6832b1cd19756" }, "downloads": -1, "filename": "maybe-else-0.0.5.tar.gz", "has_sig": false, "md5_digest": "993ecbce69fb7d2a237db4b35b394645", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4500, "upload_time": "2019-09-01T00:15:43", "url": "https://files.pythonhosted.org/packages/3e/45/81231af49b54808dd251fd2720ebec81e818237eb415dd50c1f2a73b305e/maybe-else-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f0db4ac3a222e76023fa67dc2697ee81", "sha256": "5b7ad0fda4ab9801103ebc593415682a7c3e426e8d1f906b759d6eb724fb4813" }, "downloads": -1, "filename": "maybe_else-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "f0db4ac3a222e76023fa67dc2697ee81", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5277, "upload_time": "2019-09-01T00:15:42", "url": "https://files.pythonhosted.org/packages/55/03/31696038c43a3c62d10ba026544aa7122189406173b42f59f25d090455f3/maybe_else-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "993ecbce69fb7d2a237db4b35b394645", "sha256": "743c0e6d912ef016b9facf151cc660c5c096eb70db39c04c45a6832b1cd19756" }, "downloads": -1, "filename": "maybe-else-0.0.5.tar.gz", "has_sig": false, "md5_digest": "993ecbce69fb7d2a237db4b35b394645", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4500, "upload_time": "2019-09-01T00:15:43", "url": "https://files.pythonhosted.org/packages/3e/45/81231af49b54808dd251fd2720ebec81e818237eb415dd50c1f2a73b305e/maybe-else-0.0.5.tar.gz" } ] }