Name | detool JSON |
Version |
1.1.3
JSON |
| download |
home_page | |
Summary | decorator tool collection |
upload_time | 2023-08-07 14:36:54 |
maintainer | abo123456789 |
docs_url | None |
author | abo123456789 |
requires_python | |
license | MIT License |
keywords |
detool
decorators
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![Supported Versions](https://img.shields.io/pypi/pyversions/leek.svg)](https://pypi.org/project/leek)
### 常用装饰器工具集
#### pip安装
```shell
pip install detool
```
#### 1.统计函数执行时长装饰器
```python
import time
from detool import timer_cost
@timer_cost
def t_time():
time.sleep(0.01)
print(123)
```
#### 2.redis缓存装饰器
```python
from detool import RedisCache
redis_cache = RedisCache(host='127.0.0.1', password='', port=6379, db=0)
@redis_cache.cache(ttl=30)
def sum_t(a, b):
print(f'{a}+{b}={a + b}')
return a + b
r = sum_t(1, 2)
print(r)
```
#### 3.日志装饰器
```python
from detool import class_log_decorator,log_decorator
@class_log_decorator
class Cal(object):
def __init__(self, c):
self.c = c
def sum(self, a, b):
return a + b
@log_decorator
def calculate(a, b):
return a + b
Cal(3).sum(a=3, b=6)
```
#### 4.异常捕获装饰器
```python
from detool import class_exception_decorator,exception_decorator
@exception_decorator
def r_exception():
raise Exception("function Exception raised")
@class_exception_decorator
class ClassException(object):
def r_exception(self):
raise Exception("class Exception raised")
r_exception()
ClassException().r_exception()
```
#### 5.分析内存装饰器
```python
from detool import profile
@profile
def t_memory():
return [i for i in range(1, 1001)]
t_memory()
```
Raw data
{
"_id": null,
"home_page": "",
"name": "detool",
"maintainer": "abo123456789",
"docs_url": null,
"requires_python": "",
"maintainer_email": "abcdef123456chen@sohu.com",
"keywords": "detool,decorators",
"author": "abo123456789",
"author_email": "abcdef123456chen@sohu.com",
"download_url": "https://files.pythonhosted.org/packages/15/ce/47b230634ee3dc66f8de875ed155b0ff40d7e51c2ff24eebf3ba14662cf0/detool-1.1.3.tar.gz",
"platform": "all",
"description": "[![Supported Versions](https://img.shields.io/pypi/pyversions/leek.svg)](https://pypi.org/project/leek)\n### \u5e38\u7528\u88c5\u9970\u5668\u5de5\u5177\u96c6\n\n#### pip\u5b89\u88c5\n```shell\npip install detool\n```\n\n#### 1.\u7edf\u8ba1\u51fd\u6570\u6267\u884c\u65f6\u957f\u88c5\u9970\u5668\n```python\nimport time\nfrom detool import timer_cost\n\n@timer_cost\ndef t_time():\n time.sleep(0.01)\n print(123)\n```\n\n#### 2.redis\u7f13\u5b58\u88c5\u9970\u5668\n```python\n from detool import RedisCache\n\n redis_cache = RedisCache(host='127.0.0.1', password='', port=6379, db=0)\n\n @redis_cache.cache(ttl=30)\n def sum_t(a, b):\n print(f'{a}+{b}={a + b}')\n return a + b\n\n r = sum_t(1, 2)\n print(r)\n```\n#### 3.\u65e5\u5fd7\u88c5\u9970\u5668\n```python\n from detool import class_log_decorator,log_decorator\n\n @class_log_decorator\n class Cal(object):\n def __init__(self, c):\n self.c = c\n\n def sum(self, a, b):\n return a + b\n @log_decorator\n def calculate(a, b):\n return a + b\n\n Cal(3).sum(a=3, b=6)\n```\n\n#### 4.\u5f02\u5e38\u6355\u83b7\u88c5\u9970\u5668\n```python\n from detool import class_exception_decorator,exception_decorator\n\n @exception_decorator\n def r_exception():\n raise Exception(\"function Exception raised\")\n\n\n @class_exception_decorator\n class ClassException(object):\n def r_exception(self):\n raise Exception(\"class Exception raised\")\n\n\n r_exception()\n ClassException().r_exception()\n```\n\n#### 5.\u5206\u6790\u5185\u5b58\u88c5\u9970\u5668\n```python\n from detool import profile\n\n @profile\n def t_memory():\n return [i for i in range(1, 1001)]\n\n t_memory()\n```\n\n\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "decorator tool collection",
"version": "1.1.3",
"project_urls": null,
"split_keywords": [
"detool",
"decorators"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "89c604342b09fea0c62214046a556403eeaf679a73889fcb755e68599739972b",
"md5": "e1b81632893ab7eaf12b92cd1f8274c3",
"sha256": "93c0e28ed549e82adc03891fed7a58b2a48500b442c47f9071439747ad58a87d"
},
"downloads": -1,
"filename": "detool-1.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e1b81632893ab7eaf12b92cd1f8274c3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7766,
"upload_time": "2023-08-07T14:36:50",
"upload_time_iso_8601": "2023-08-07T14:36:50.242812Z",
"url": "https://files.pythonhosted.org/packages/89/c6/04342b09fea0c62214046a556403eeaf679a73889fcb755e68599739972b/detool-1.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "15ce47b230634ee3dc66f8de875ed155b0ff40d7e51c2ff24eebf3ba14662cf0",
"md5": "41e053a9bbbd535b526ca1ab6ff2e21c",
"sha256": "8702aa10982ef2c3465d4b5f26e552c7bc4f9e4fb1cff4ec5caf90bbd3b358c9"
},
"downloads": -1,
"filename": "detool-1.1.3.tar.gz",
"has_sig": false,
"md5_digest": "41e053a9bbbd535b526ca1ab6ff2e21c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4002,
"upload_time": "2023-08-07T14:36:54",
"upload_time_iso_8601": "2023-08-07T14:36:54.392597Z",
"url": "https://files.pythonhosted.org/packages/15/ce/47b230634ee3dc66f8de875ed155b0ff40d7e51c2ff24eebf3ba14662cf0/detool-1.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-07 14:36:54",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "detool"
}