Name | otsunotificationfrequency JSON |
Version |
1.0.4.311
JSON |
| download |
home_page | https://github.com/Otsuhachi/NotificationFrequency |
Summary | 要素数が確定されたシーケンスの途中で処理を挟むタイミングの判定を補助します。 |
upload_time | 2023-01-20 22:01:31 |
maintainer | |
docs_url | None |
author | Otsuhachi |
requires_python | >=3.11 |
license | MIT License Copyright (c) 2022 Otsuhachi 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
notification
frequency
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# NotificationFrequency
要素数が確定されたシーケンスの途中で処理を挟むタイミングの判定を補助します。
## 使い方
1. `n回毎`あるいは`n%毎`など、頻度を指定してインスタンス`nf`を生成します。
1. `nf.length`に管理するシーケンスの要素数を与えます。
1. `enumerate`付きの`for文`などで(`通知を行うか否か(bool)`, `進捗率(int)`)を取得できます。
```Python
from otsunotificationfrequency import NotificationFrequency
# 2212個の要素を持つリストで実行する例
data = [x * 2 for x in range(2212)]
length = len(data)
# 25%毎に表示を行う
nf25per = NotificationFrequency('25%')
nf25per.set_length(length)
# 20個毎に表示を行う
# nf20 = NotificationFrequency(20)
# nf20.length = length
for i, d in enumerate(data):
i += 1
sa, per = nf25per.check_and_get_percentage(i)
# sa, per = nf20(i)
if sa:
print(f'{d}: {per}% ({i}/{length})')
```
`25%`毎に表示する例
```console
1104: 25% (553/2212)
2210: 50% (1106/2212)
3316: 75% (1659/2212)
4422: 100% (2212/2212)
```
`20個`毎に表示する例
```console
38: 0% (20/2212)
78: 1% (40/2212)
118: 2% (60/2212)
158: 3% (80/2212)
198: 4% (100/2212)
238: 5% (120/2212)
278: 6% (140/2212)
318: 7% (160/2212)
358: 8% (180/2212)
398: 9% (200/2212)
438: 9% (220/2212)
...
4158: 94% (2080/2212)
4198: 94% (2100/2212)
4238: 95% (2120/2212)
4278: 96% (2140/2212)
4318: 97% (2160/2212)
4358: 98% (2180/2212)
4398: 99% (2200/2212)
4422: 100% (2212/2212)
```
## otsunotificationfrequency.validatorモジュール
`otsuvalidator`ライブラリがインストールされていない場合インポートできず、`ImportError`が発生します。
`otsucfgmng`などでバリデータやコンバータが必要な場合に利用してください。
`NotificationFrequency`を使用するだけの場合、このモジュールは何の機能も持ちません。
Raw data
{
"_id": null,
"home_page": "https://github.com/Otsuhachi/NotificationFrequency",
"name": "otsunotificationfrequency",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "",
"keywords": "Python Notification Frequency",
"author": "Otsuhachi",
"author_email": "agequodagis.tufuiegoeris@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ff/22/c97cee281e8445f95609c3e7e167dc9780e6ada15efa28329db708570f10/otsunotificationfrequency-1.0.4.311.tar.gz",
"platform": null,
"description": "# NotificationFrequency\r\n\r\n\u8981\u7d20\u6570\u304c\u78ba\u5b9a\u3055\u308c\u305f\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u9014\u4e2d\u3067\u51e6\u7406\u3092\u631f\u3080\u30bf\u30a4\u30df\u30f3\u30b0\u306e\u5224\u5b9a\u3092\u88dc\u52a9\u3057\u307e\u3059\u3002 \r\n\r\n## \u4f7f\u3044\u65b9\r\n\r\n1. `n\u56de\u6bce`\u3042\u308b\u3044\u306f`n%\u6bce`\u306a\u3069\u3001\u983b\u5ea6\u3092\u6307\u5b9a\u3057\u3066\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9`nf`\u3092\u751f\u6210\u3057\u307e\u3059\u3002\r\n1. `nf.length`\u306b\u7ba1\u7406\u3059\u308b\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u8981\u7d20\u6570\u3092\u4e0e\u3048\u307e\u3059\u3002\r\n1. `enumerate`\u4ed8\u304d\u306e`for\u6587`\u306a\u3069\u3067(`\u901a\u77e5\u3092\u884c\u3046\u304b\u5426\u304b(bool)`, `\u9032\u6357\u7387(int)`)\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\r\n\r\n```Python\r\n\r\nfrom otsunotificationfrequency import NotificationFrequency\r\n\r\n# 2212\u500b\u306e\u8981\u7d20\u3092\u6301\u3064\u30ea\u30b9\u30c8\u3067\u5b9f\u884c\u3059\u308b\u4f8b\r\ndata = [x * 2 for x in range(2212)]\r\nlength = len(data)\r\n\r\n# 25%\u6bce\u306b\u8868\u793a\u3092\u884c\u3046\r\nnf25per = NotificationFrequency('25%')\r\nnf25per.set_length(length)\r\n\r\n# 20\u500b\u6bce\u306b\u8868\u793a\u3092\u884c\u3046\r\n# nf20 = NotificationFrequency(20)\r\n# nf20.length = length\r\n\r\nfor i, d in enumerate(data):\r\n i += 1\r\n sa, per = nf25per.check_and_get_percentage(i)\r\n # sa, per = nf20(i)\r\n if sa:\r\n print(f'{d}: {per}% ({i}/{length})')\r\n```\r\n\r\n`25%`\u6bce\u306b\u8868\u793a\u3059\u308b\u4f8b \r\n\r\n```console\r\n\r\n1104: 25% (553/2212)\r\n2210: 50% (1106/2212)\r\n3316: 75% (1659/2212)\r\n4422: 100% (2212/2212)\r\n```\r\n\r\n`20\u500b`\u6bce\u306b\u8868\u793a\u3059\u308b\u4f8b\r\n\r\n```console\r\n\r\n38: 0% (20/2212)\r\n78: 1% (40/2212)\r\n118: 2% (60/2212)\r\n158: 3% (80/2212)\r\n198: 4% (100/2212)\r\n238: 5% (120/2212)\r\n278: 6% (140/2212)\r\n318: 7% (160/2212)\r\n358: 8% (180/2212)\r\n398: 9% (200/2212)\r\n438: 9% (220/2212)\r\n...\r\n4158: 94% (2080/2212)\r\n4198: 94% (2100/2212)\r\n4238: 95% (2120/2212)\r\n4278: 96% (2140/2212)\r\n4318: 97% (2160/2212)\r\n4358: 98% (2180/2212)\r\n4398: 99% (2200/2212)\r\n4422: 100% (2212/2212)\r\n```\r\n\r\n## otsunotificationfrequency.validator\u30e2\u30b8\u30e5\u30fc\u30eb\r\n\r\n`otsuvalidator`\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u30a4\u30f3\u30dd\u30fc\u30c8\u3067\u304d\u305a\u3001`ImportError`\u304c\u767a\u751f\u3057\u307e\u3059\u3002 \r\n`otsucfgmng`\u306a\u3069\u3067\u30d0\u30ea\u30c7\u30fc\u30bf\u3084\u30b3\u30f3\u30d0\u30fc\u30bf\u304c\u5fc5\u8981\u306a\u5834\u5408\u306b\u5229\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002 \r\n`NotificationFrequency`\u3092\u4f7f\u7528\u3059\u308b\u3060\u3051\u306e\u5834\u5408\u3001\u3053\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u4f55\u306e\u6a5f\u80fd\u3082\u6301\u3061\u307e\u305b\u3093\u3002\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2022 Otsuhachi 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": "\u8981\u7d20\u6570\u304c\u78ba\u5b9a\u3055\u308c\u305f\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u9014\u4e2d\u3067\u51e6\u7406\u3092\u631f\u3080\u30bf\u30a4\u30df\u30f3\u30b0\u306e\u5224\u5b9a\u3092\u88dc\u52a9\u3057\u307e\u3059\u3002",
"version": "1.0.4.311",
"split_keywords": [
"python",
"notification",
"frequency"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "220ce8d8be46ebf614566e0800a785096694136ae5bda60fdfab889759203de5",
"md5": "2f2ff721927418d246b9a3f2dba08a54",
"sha256": "377edba32c16133bfe2c3a9e057c5733561dd5f309a835fa22b8bcccbbf641cb"
},
"downloads": -1,
"filename": "otsunotificationfrequency-1.0.4.311-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2f2ff721927418d246b9a3f2dba08a54",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 7760,
"upload_time": "2023-01-20T22:01:28",
"upload_time_iso_8601": "2023-01-20T22:01:28.868310Z",
"url": "https://files.pythonhosted.org/packages/22/0c/e8d8be46ebf614566e0800a785096694136ae5bda60fdfab889759203de5/otsunotificationfrequency-1.0.4.311-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ff22c97cee281e8445f95609c3e7e167dc9780e6ada15efa28329db708570f10",
"md5": "6d4cb8a4cf12b5eb67f0cc5c7bae95d4",
"sha256": "744eb000ec6fc0b8d3e54dcc2f678905b096e220dd396cdda6522e9ffa9dfe2a"
},
"downloads": -1,
"filename": "otsunotificationfrequency-1.0.4.311.tar.gz",
"has_sig": false,
"md5_digest": "6d4cb8a4cf12b5eb67f0cc5c7bae95d4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 5591,
"upload_time": "2023-01-20T22:01:31",
"upload_time_iso_8601": "2023-01-20T22:01:31.166707Z",
"url": "https://files.pythonhosted.org/packages/ff/22/c97cee281e8445f95609c3e7e167dc9780e6ada15efa28329db708570f10/otsunotificationfrequency-1.0.4.311.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-20 22:01:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Otsuhachi",
"github_project": "NotificationFrequency",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "otsunotificationfrequency"
}