Name | divert JSON |
Version |
0.1.0
JSON |
| download |
home_page | |
Summary | Divert the execution flow. |
upload_time | 2023-10-16 23:36:33 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.10 |
license | |
keywords |
execution
flow
divert
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Divert
Divert the execution flow of your code.
This is useful for complex code with lots of method nesting and unpredictable return values.
Plus, no sub-dependencies.
## Example usage
For example, if we have an inner function (or multiple), we can immediately divert to a flow edge of our choice.
```python
from divert.flow import custom_flow_edge, divert
def inner_function(number: int) -> int:
"""Function that doubles the value or signals that the flow should change."""
if number == 4: # Stop condition for sake of example
divert() # If we want to specify the return value here we can instead use `payload_to_edge(VALUE)`
return number * 2
@custom_flow_edge(default_return=42)
def outer_function() -> int:
"""Larger function that calls the inner function multiple times."""
first_response = inner_function(2)
second_response = inner_function(4)
third_response = inner_function(8)
return first_response + second_response + third_response
```
For further motivation for using the library, see [the documentation](examples/motivation.md).
For example usage, see [the examples](examples/).
Raw data
{
"_id": null,
"home_page": "",
"name": "divert",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "execution,flow,divert",
"author": "",
"author_email": "Ben <22123881+simonsben@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/aa/7c/51a236167f32d2af20a061c220ee608abc7b6288b65ed626a9f4c96a3aa0/divert-0.1.0.tar.gz",
"platform": null,
"description": "# Divert\n\nDivert the execution flow of your code.\nThis is useful for complex code with lots of method nesting and unpredictable return values.\n\nPlus, no sub-dependencies.\n\n## Example usage\n\nFor example, if we have an inner function (or multiple), we can immediately divert to a flow edge of our choice.\n\n```python\nfrom divert.flow import custom_flow_edge, divert\n\n\ndef inner_function(number: int) -> int:\n \"\"\"Function that doubles the value or signals that the flow should change.\"\"\"\n if number == 4: # Stop condition for sake of example\n divert() # If we want to specify the return value here we can instead use `payload_to_edge(VALUE)`\n\n return number * 2\n\n\n@custom_flow_edge(default_return=42)\ndef outer_function() -> int:\n \"\"\"Larger function that calls the inner function multiple times.\"\"\"\n first_response = inner_function(2)\n second_response = inner_function(4)\n third_response = inner_function(8)\n\n return first_response + second_response + third_response\n```\n\nFor further motivation for using the library, see [the documentation](examples/motivation.md).\nFor example usage, see [the examples](examples/).\n",
"bugtrack_url": null,
"license": "",
"summary": "Divert the execution flow.",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [
"execution",
"flow",
"divert"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "720f14a46e25348c70242adafdbf04ca63faa94b97185ab2bc140caca921fcaa",
"md5": "09c5b7e9fd72572583580d63b150616f",
"sha256": "d3ce5af62af8f55b584bf97414529c8cbc7d8e5bed4c537dd36f7c5558cb085d"
},
"downloads": -1,
"filename": "divert-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "09c5b7e9fd72572583580d63b150616f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 3650,
"upload_time": "2023-10-16T23:36:32",
"upload_time_iso_8601": "2023-10-16T23:36:32.017056Z",
"url": "https://files.pythonhosted.org/packages/72/0f/14a46e25348c70242adafdbf04ca63faa94b97185ab2bc140caca921fcaa/divert-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aa7c51a236167f32d2af20a061c220ee608abc7b6288b65ed626a9f4c96a3aa0",
"md5": "4f581245ec83d737ca1863bf312ae513",
"sha256": "be5cef0d59febd05d7f6409da38edecc5ab9261aa75577579b2e9e40a35b4567"
},
"downloads": -1,
"filename": "divert-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "4f581245ec83d737ca1863bf312ae513",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 3865,
"upload_time": "2023-10-16T23:36:33",
"upload_time_iso_8601": "2023-10-16T23:36:33.552073Z",
"url": "https://files.pythonhosted.org/packages/aa/7c/51a236167f32d2af20a061c220ee608abc7b6288b65ed626a9f4c96a3aa0/divert-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-16 23:36:33",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "divert"
}