{ "info": { "author": "ALiCE Biometrics", "author_email": "support@alicebiometrics.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3" ], "description": "meiga\n=====\n\nA simple, typed and monad-based Result type for Python.\n\nThis package provides a new type for your Python applications, the Result[Type, Type].\nThis Result type allows to define two subtypes, giving us the option to create useful return types.\n\nThis package is based in another solutions from another modern languages as the swift-based [Result](https://github.com/antitypical/Result) implementation.\n\n#### Installation \n\n~~~\npip install meiga\n~~~\n\n#### Getting Started\n\n**meiga** is a framework that give us a simpler, clearer way of handling errors in Python. Use it whenever a class method or a function has the possibility of failure. \n\nConsider the following example of a function that tries to extract a String (str) for a given key from a Dict.\n\n~~~\nfrom meiga import Result, Error\n\n\nclass NoSuchKey(Error):\n pass\n\n\nclass TypeMismatch(Error):\n pass\n\n\ndef string_from_key(dictionary: dict, key: str) -> Result[str, Error]:\n if key not in dictionary.keys():\n return Result(failure=NoSuchKey())\n\n value = dictionary[key]\n if not isinstance(value, str):\n return Result(failure=TypeMismatch())\n\n return Result(success=value)\n~~~\n\nResult meiga type provides a robust wrapper around the functions.\nRather than throw an exception, it returns a Result that either contains the String value for the given key, or an ErrorClass detailing what went wrong.\n\n#### Result Type\n\nLet's image we have a dictionary that represent a user info data\n\n~~~\n>>> user_info = {\"first_name\": \"Rosalia\", \"last_name\": \"De Castro\", \"age\": 60}\n~~~\n\nAnd we try to obtain **first_name** \n\n~~~\n>>> result = string_from_key(dictionary=user_info, key=\"first_name\")\nResult[status: success | value: Rosalia]\n~~~\n\nYou can check the status of the result\n\n~~~\n>>> result.is_success\nTrue\n>>> result.is_failure\nFalse\n~~~\n\nIf the result is a success you can get the expected value\n\n~~~\n>>> result.value\nRosalia \n~~~\n\nOtherwise, if we try to access an invalid key or a non string value, returned result will be a failure.\n\n~~~\n>>> result = string_from_key(dictionary=user_info, key=\"invalid_key\")\nResult[status: failure | value: NoSuchKey]\n>>> result.is_failure\nTrue\n>>> result.value\nNoSuchKey() // Error \n~~~\n\nOr\n\n~~~\n>>> result = string_from_key(dictionary=user_info, key=\"age\")\nResult[status: failure | value: TypeMismatch]\n>>> result.is_failure\nTrue\n>>> result.value\nTypeMismatch() // Error \n~~~\n\n# Handle Result\n\nThis framework also allows a method for handling Result type\n\nWhen the operations is executed with its happy path, handle function returns the success value, as with result.value.\n\n~~~\n>>> result = string_from_key(dictionary=user_info, key=\"first_name\")\nResult[status: success | value: Rosalia]\n>>> first_name = result.handle()\nRosalia\n~~~\n\nOn the other hand, if something wrong happens handle function will raise an Exception (ReturnErrorOnFailure)\n\nAdditionally, handle a Result with the meiga decorator allows to return a typed error when a sub-function fails.\n\n~~~\nfrom meiga import Result, Error\nfrom meiga.decorators import meiga\n\n@meiga\ndef handling_result(key: str) -> Result:\n user_info = {\"first_name\": \"Rosalia\", \"last_name\": \"De Castro\", \"age\": 60}\n first_name = string_from_key(dictionary=user_info, key=key).handle() \n # Do whatever with the name\n name = first_name.lower()\n return Result(success=name)\n~~~\n\nIf key is valid success value would be returned. Otherwise, an Error would be returned.\n\n\n## Developers\n\n##### Install requirements\n\n~~~\npip install -r requirements/dev.txt\n~~~\n\n##### Test\n\n~~~\npip install -e . && pytest\n~~~\n\n##### Upload to pip \n\n~~~\npython setup.py sdist bdist_wheel\ntwine upload --repository-url https://upload.pypi.org/legacy/ dist/*\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/alice-biometrics/meiga", "keywords": "Result,Monad,Typed,Typing", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "meiga", "package_url": "https://pypi.org/project/meiga/", "platform": "", "project_url": "https://pypi.org/project/meiga/", "project_urls": { "Homepage": "https://github.com/alice-biometrics/meiga" }, "release_url": "https://pypi.org/project/meiga/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "A simple, typed and monad-based Result type for Python", "version": "0.1.1" }, "last_serial": 5881100, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "da33bab5670be9f7de4197fe3ad6f5a8", "sha256": "65539ce164a5f485a46de206cf287d62d6613b1519f5b78b2b5a447a706da606" }, "downloads": -1, "filename": "meiga-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "da33bab5670be9f7de4197fe3ad6f5a8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7333, "upload_time": "2019-09-03T06:17:40", "url": "https://files.pythonhosted.org/packages/0d/60/fc979c3a8690b1df589ea112c3495d0419c91a8aa0c7e7841ed6ce077521/meiga-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1d62da2fde4dd5425dd9d85e0efb20bb", "sha256": "4a12936aa645979c191c6a67f45d1b797f3e317eddd28f4c065ce04a9ee64931" }, "downloads": -1, "filename": "meiga-0.0.1.tar.gz", "has_sig": false, "md5_digest": "1d62da2fde4dd5425dd9d85e0efb20bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5166, "upload_time": "2019-09-03T06:17:42", "url": "https://files.pythonhosted.org/packages/b2/6b/4afafc15b0e4f752cdf8611e94e7fa1d04f3c1cadced4d705c60fd516be4/meiga-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "dd0550345710c3f8790bc44e497f1524", "sha256": "a3571d533b46da27fbf52eebb2c1e1293aff9d3eddee16dfecc67c136b93f1ab" }, "downloads": -1, "filename": "meiga-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "dd0550345710c3f8790bc44e497f1524", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7272, "upload_time": "2019-09-03T06:27:41", "url": "https://files.pythonhosted.org/packages/fd/1b/ff51e46b1a5a33d916d48f017d3cfa274902286ccb61ec5b471bea7bffc6/meiga-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a2978b1ee22e41f0267d13ba15f30507", "sha256": "5a1890032849bd5945d5d7bfb916c2304da9cfb4e619af71e5c325e1c7f4f0a4" }, "downloads": -1, "filename": "meiga-0.0.2.tar.gz", "has_sig": false, "md5_digest": "a2978b1ee22e41f0267d13ba15f30507", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5099, "upload_time": "2019-09-03T06:27:43", "url": "https://files.pythonhosted.org/packages/27/d8/d0cd688a7b4021af994f7bde8dbe22760c6f64ef8c38a1e7f02dc955bfb5/meiga-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "ddfaa5d1ca26a4dc0a1a695fbdde27e7", "sha256": "73254a04e34ca820cf510f51ce755e67eaaf0bdd874603fd26f04da9b0952009" }, "downloads": -1, "filename": "meiga-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "ddfaa5d1ca26a4dc0a1a695fbdde27e7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7349, "upload_time": "2019-09-03T09:10:24", "url": "https://files.pythonhosted.org/packages/ee/4f/9e5a33e82dd5b420ac4ebe9f4ccafdbd9abf35134e90be4d85f67e5e79c6/meiga-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "279d3e5f5f75d5bd4bab0ae1774c4c76", "sha256": "e0ba82cf76dd1ec0dd1240a3dd3f44bc131b4b7e507af056be1c6f3e58a47852" }, "downloads": -1, "filename": "meiga-0.0.3.tar.gz", "has_sig": false, "md5_digest": "279d3e5f5f75d5bd4bab0ae1774c4c76", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5137, "upload_time": "2019-09-03T09:10:25", "url": "https://files.pythonhosted.org/packages/36/60/54bde0dfe283c95ee86dbdc59492c6b535928071805d7167523c3606c335/meiga-0.0.3.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "8284c7d591013eadd14904e76dfdc953", "sha256": "f5fc22a2723733cc2633b5659fffc56aa2bc9c777e2d0bd9e13a3b5fae596c55" }, "downloads": -1, "filename": "meiga-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "8284c7d591013eadd14904e76dfdc953", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7550, "upload_time": "2019-09-03T20:43:47", "url": "https://files.pythonhosted.org/packages/43/66/081e680caef1702d64291017bc172b919e8434394a0a59e71c9552d25cca/meiga-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a49f419cb86cf820be34d579a44bd639", "sha256": "29597aa47791920a4d2e092ff5b8e1fd65b2a0f39bcab8406729d247546d489f" }, "downloads": -1, "filename": "meiga-0.1.0.tar.gz", "has_sig": false, "md5_digest": "a49f419cb86cf820be34d579a44bd639", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5120, "upload_time": "2019-09-03T20:43:49", "url": "https://files.pythonhosted.org/packages/e0/b1/b4a8fa5729ab5a1d239e53d1848026b4032ac02afcc909dbae81f37caf7f/meiga-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4b66998f397f569176eb1a749d775d2a", "sha256": "7e48209293a8d740f9914254ab50b0cc985f801af72e975eed1ce2d32a6b9b8b" }, "downloads": -1, "filename": "meiga-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4b66998f397f569176eb1a749d775d2a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8565, "upload_time": "2019-09-24T17:24:04", "url": "https://files.pythonhosted.org/packages/ea/c5/3b0d87c3a572f7c52d333b968631084c05ab74f0a3f54f172b4799bb88e4/meiga-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0ed9cb7498dea59461673074fd3dd74d", "sha256": "c581496970ef99615a314c9554de146b6460839b3e08c278c0d8776f68542e4a" }, "downloads": -1, "filename": "meiga-0.1.1.tar.gz", "has_sig": false, "md5_digest": "0ed9cb7498dea59461673074fd3dd74d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6012, "upload_time": "2019-09-24T17:24:06", "url": "https://files.pythonhosted.org/packages/af/9b/daf9b84fdc822db4204ef0518aacca2588cd3439952b968cb39dd16dad1e/meiga-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4b66998f397f569176eb1a749d775d2a", "sha256": "7e48209293a8d740f9914254ab50b0cc985f801af72e975eed1ce2d32a6b9b8b" }, "downloads": -1, "filename": "meiga-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4b66998f397f569176eb1a749d775d2a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8565, "upload_time": "2019-09-24T17:24:04", "url": "https://files.pythonhosted.org/packages/ea/c5/3b0d87c3a572f7c52d333b968631084c05ab74f0a3f54f172b4799bb88e4/meiga-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0ed9cb7498dea59461673074fd3dd74d", "sha256": "c581496970ef99615a314c9554de146b6460839b3e08c278c0d8776f68542e4a" }, "downloads": -1, "filename": "meiga-0.1.1.tar.gz", "has_sig": false, "md5_digest": "0ed9cb7498dea59461673074fd3dd74d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6012, "upload_time": "2019-09-24T17:24:06", "url": "https://files.pythonhosted.org/packages/af/9b/daf9b84fdc822db4204ef0518aacca2588cd3439952b968cb39dd16dad1e/meiga-0.1.1.tar.gz" } ] }