要素数が確定されたシーケンスの途中で処理を挟むタイミングの判定を補助します。
Project description
NotificationFrequency
要素数が確定されたシーケンスの途中で処理を挟むタイミングの判定を補助します。
使い方
n回毎あるいはn%毎など、頻度を指定してインスタンスnfを生成します。nf.lengthに管理するシーケンスの要素数を与えます。enumerate付きのfor文などで(通知を行うか否か(bool),進捗率(int))を取得できます。
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%毎に表示する例
1104: 25% (553/2212)
2210: 50% (1106/2212)
3316: 75% (1659/2212)
4422: 100% (2212/2212)
20個毎に表示する例
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を使用するだけの場合、このモジュールは何の機能も持ちません。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file otsunotificationfrequency-1.0.4.311.tar.gz.
File metadata
- Download URL: otsunotificationfrequency-1.0.4.311.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
744eb000ec6fc0b8d3e54dcc2f678905b096e220dd396cdda6522e9ffa9dfe2a
|
|
| MD5 |
6d4cb8a4cf12b5eb67f0cc5c7bae95d4
|
|
| BLAKE2b-256 |
ff22c97cee281e8445f95609c3e7e167dc9780e6ada15efa28329db708570f10
|
File details
Details for the file otsunotificationfrequency-1.0.4.311-py3-none-any.whl.
File metadata
- Download URL: otsunotificationfrequency-1.0.4.311-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
377edba32c16133bfe2c3a9e057c5733561dd5f309a835fa22b8bcccbbf641cb
|
|
| MD5 |
2f2ff721927418d246b9a3f2dba08a54
|
|
| BLAKE2b-256 |
220ce8d8be46ebf614566e0800a785096694136ae5bda60fdfab889759203de5
|