Name | nix-python-utils JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | Useful Python decorators that I use in development. |
upload_time | 2024-05-07 13:25:16 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.11 |
license | MIT License Copyright (c) 2024 Nix ツ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
python
utils
useful
library
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# nix-python-utils
**Description**:
A collection of versatile classes, methods and decorators that I frequently use across my work projects.
## Content
- [Install](#Install)
- [Classes](#Classes)
- [Decorators](#Decorators)
- [Licence](#Licence)
##Install
```bash
pip install nix-python-utils
```
## Classes
For use classes you need to import them from the package:
```python
import nix.classes as classes
```
| Method | Parameters | Returns | Description |
|----------------------------------|----------------------------------------------------------|---------|---------------------------------------------------------------------------|
| `IO.read_file` | - `file_path` (str): The path to the file to read. | `str` | Reads a file from the specified path and returns its content as a string. |
| `IO.write_file` | - `file_path` (str): The path to the file to write to. | `None` | Writes the given content to the specified file. |
| | - `content` (str): The content to write to the file. | | |
| `IO.create_folder_if_not_exists` | - `folder_path` (str): The path to the folder to create. | `None` | Creates a folder at the specified path if it does not already exist. |
## Decorators
For use decorators you need to import them from the package:
```python
import nix.utils.decorators as decorators
```
| Decorator | Arguments | Description |
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| @retry | - `max_retries` (int, default=3) <br> - `delay` (int, default=2) <br> - `exceptions` (Exception or tuple of Exceptions, default=Exception) <br> - `backoff_factor` (int, default=1) <br> - `logger` (Logger, optional) | A decorator that retries a function upon failure. You can customize the maximum number of retries, the delay between retries, the type of exceptions to catch, and the backoff factor to increase the delay with each retry. If a logger is provided, exceptions are logged. |
| @thread_pool | - `num_threads` (int, default=4) <br> - `exceptions` (Exception or tuple of Exceptions, default=Exception) <br> - `raise_first_exception` (bool, default=False) <br> - `logger` (Logger, optional) | A decorator that runs a function in a thread pool with a specified number of threads. It collects results from all tasks and returns them as a list. It also handles exceptions, with an option to re-raise the first exception or just log it. |
| @handle_exception | - `handler` (Callable[[Exception], Any], optional) <br> - `exceptions` (Exception or tuple of Exceptions, default=Exception) <br> - `default_value` (Any, optional) <br> - `raise_exception` (bool, default=False) <br> - `logger` (Logger, optional) | A decorator for handling exceptions in a function. You can specify a custom exception handler, the type of exceptions to catch, a default return value if exceptions occur, and whether to re-raise exceptions. Logging is optional and can be controlled with a logger. It also supports additional arguments and keyword arguments for the exception handler. |
## Licence
This project is licensed under the MIT License. See the LICENSE file for more details.
Raw data
{
"_id": null,
"home_page": null,
"name": "nix-python-utils",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "Nix \u30c4 <nikusunix@gmail.com>",
"keywords": "python, utils, useful, library",
"author": null,
"author_email": "Nix \u30c4 <nikusunix@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/5b/fe/f08dfaadc665f6c33573489b929a13be08522f3138729577d3174f1f58f0/nix_python_utils-0.1.0.tar.gz",
"platform": null,
"description": "# nix-python-utils\n\n**Description**:\nA collection of versatile classes, methods and decorators that I frequently use across my work projects.\n\n## Content\n\n- [Install](#Install)\n- [Classes](#Classes)\n- [Decorators](#Decorators)\n- [Licence](#Licence)\n\n##Install\n\n```bash\npip install nix-python-utils\n```\n\n## Classes\n\nFor use classes you need to import them from the package:\n\n```python\nimport nix.classes as classes\n```\n\n| Method | Parameters | Returns | Description |\n|----------------------------------|----------------------------------------------------------|---------|---------------------------------------------------------------------------|\n| `IO.read_file` | - `file_path` (str): The path to the file to read. | `str` | Reads a file from the specified path and returns its content as a string. |\n| `IO.write_file` | - `file_path` (str): The path to the file to write to. | `None` | Writes the given content to the specified file. |\n| | - `content` (str): The content to write to the file. | | |\n| `IO.create_folder_if_not_exists` | - `folder_path` (str): The path to the folder to create. | `None` | Creates a folder at the specified path if it does not already exist. |\n\n## Decorators\n\nFor use decorators you need to import them from the package:\n\n```python\nimport nix.utils.decorators as decorators\n```\n\n| Decorator | Arguments | Description |\n|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| @retry | - `max_retries` (int, default=3) <br> - `delay` (int, default=2) <br> - `exceptions` (Exception or tuple of Exceptions, default=Exception) <br> - `backoff_factor` (int, default=1) <br> - `logger` (Logger, optional) | A decorator that retries a function upon failure. You can customize the maximum number of retries, the delay between retries, the type of exceptions to catch, and the backoff factor to increase the delay with each retry. If a logger is provided, exceptions are logged. |\n| @thread_pool | - `num_threads` (int, default=4) <br> - `exceptions` (Exception or tuple of Exceptions, default=Exception) <br> - `raise_first_exception` (bool, default=False) <br> - `logger` (Logger, optional) | A decorator that runs a function in a thread pool with a specified number of threads. It collects results from all tasks and returns them as a list. It also handles exceptions, with an option to re-raise the first exception or just log it. |\n| @handle_exception | - `handler` (Callable[[Exception], Any], optional) <br> - `exceptions` (Exception or tuple of Exceptions, default=Exception) <br> - `default_value` (Any, optional) <br> - `raise_exception` (bool, default=False) <br> - `logger` (Logger, optional) | A decorator for handling exceptions in a function. You can specify a custom exception handler, the type of exceptions to catch, a default return value if exceptions occur, and whether to re-raise exceptions. Logging is optional and can be controlled with a logger. It also supports additional arguments and keyword arguments for the exception handler. |\n\n## Licence\n\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Nix \u30c4 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Useful Python decorators that I use in development.",
"version": "0.1.0",
"project_urls": {
"Changelog": "https://github.com/nixnks/nix-python-utils/CHANGELOG.md",
"Documentation": "https://github.com/nixnks/nix-python-utils",
"Homepage": "https://github.com/nixnks/nix-python-utils",
"Repository": "https://github.com/nixnks/nix-python-utils"
},
"split_keywords": [
"python",
" utils",
" useful",
" library"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a2305f59cfb429e85a460fc272124bc0fe86c9af5ba0eda365935eb3c1f7941b",
"md5": "d2ae0dcdebed22c707ed0039f914bf6c",
"sha256": "d0d60758a84543e478f396128831d92686415015f8a67042641f4e536f67a002"
},
"downloads": -1,
"filename": "nix_python_utils-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d2ae0dcdebed22c707ed0039f914bf6c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 7802,
"upload_time": "2024-05-07T13:25:14",
"upload_time_iso_8601": "2024-05-07T13:25:14.405369Z",
"url": "https://files.pythonhosted.org/packages/a2/30/5f59cfb429e85a460fc272124bc0fe86c9af5ba0eda365935eb3c1f7941b/nix_python_utils-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5bfef08dfaadc665f6c33573489b929a13be08522f3138729577d3174f1f58f0",
"md5": "0205dcc16a5c332bfb2c98496d96dddc",
"sha256": "e1e16723f3f701ad689c554e33d05f1e12b81b5ac4710460b7fe6fb89783ccca"
},
"downloads": -1,
"filename": "nix_python_utils-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "0205dcc16a5c332bfb2c98496d96dddc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 7061,
"upload_time": "2024-05-07T13:25:16",
"upload_time_iso_8601": "2024-05-07T13:25:16.639129Z",
"url": "https://files.pythonhosted.org/packages/5b/fe/f08dfaadc665f6c33573489b929a13be08522f3138729577d3174f1f58f0/nix_python_utils-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-07 13:25:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nixnks",
"github_project": "nix-python-utils",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "nix-python-utils"
}