oafuncs 0.0.97.15__tar.gz → 0.0.97.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {oafuncs-0.0.97.15/oafuncs.egg-info → oafuncs-0.0.97.16}/PKG-INFO +1 -1
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_script/cprogressbar.py +42 -20
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_down/hycom_3hourly.py +1 -1
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_tool.py +31 -34
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16/oafuncs.egg-info}/PKG-INFO +1 -1
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/setup.py +1 -1
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/LICENSE.txt +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/MANIFEST.in +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/README.md +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/__init__.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_data/OAFuncs.png +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_data/hycom_3hourly.png +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_script/email.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_script/netcdf_merge.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_script/netcdf_modify.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_script/netcdf_write.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_script/parallel.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_script/parallel_example_usage.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_script/plot_dataset.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/_script/replace_file_concent.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_cmap.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_data.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_date.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_down/User_Agent-list.txt +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_down/__init__.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_down/idm.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_down/literature.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_down/test_ua.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_down/user_agent.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_draw.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_file.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_help.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_model/__init__.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_model/roms/__init__.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_model/roms/test.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_model/wrf/__init__.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_model/wrf/little_r.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_nc.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_python.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_sign/__init__.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_sign/meteorological.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_sign/ocean.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs/oa_sign/scientific.py +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs.egg-info/SOURCES.txt +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs.egg-info/dependency_links.txt +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs.egg-info/requires.txt +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/oafuncs.egg-info/top_level.txt +0 -0
- {oafuncs-0.0.97.15 → oafuncs-0.0.97.16}/setup.cfg +0 -0
@@ -153,6 +153,7 @@ class ColorProgressBar:
|
|
153
153
|
update_interval: float = 0.1,
|
154
154
|
bar_length: int = None,
|
155
155
|
speed_estimate_period: float = 30.0,
|
156
|
+
next_line: bool = False,
|
156
157
|
):
|
157
158
|
self.iterable = iterable
|
158
159
|
self.description = description
|
@@ -161,7 +162,7 @@ class ColorProgressBar:
|
|
161
162
|
self.update_interval = update_interval
|
162
163
|
self.bar_length = bar_length
|
163
164
|
self.speed_estimate_period = speed_estimate_period
|
164
|
-
self.
|
165
|
+
self.next_line = next_line
|
165
166
|
|
166
167
|
# 线程安全锁
|
167
168
|
self._lock = threading.RLock()
|
@@ -187,6 +188,10 @@ class ColorProgressBar:
|
|
187
188
|
self._is_terminal = hasattr(self._file, "isatty") and self._file.isatty()
|
188
189
|
self._is_jupyter = "ipykernel" in sys.modules
|
189
190
|
|
191
|
+
# 输出样式
|
192
|
+
filled_list = ["▊", "█", "▓", "▒", "░", "#", "=", ">", "▌", "▍", "▎", "▏", "*"]
|
193
|
+
self.filled = random.choice(filled_list)
|
194
|
+
|
190
195
|
def _generate_gradient(self) -> Optional[List[str]]:
|
191
196
|
"""生成渐变色列表(修复内置colormap支持)"""
|
192
197
|
try:
|
@@ -253,11 +258,7 @@ class ColorProgressBar:
|
|
253
258
|
|
254
259
|
def _format_bar(self, progress: float, width: int) -> str:
|
255
260
|
"""格式化进度条显示"""
|
256
|
-
|
257
|
-
# filled = "░"
|
258
|
-
# filled = filled_list[2] # 选择中间的填充字符
|
259
|
-
# filled = random.choice(filled_list) # 随机选择填充字符
|
260
|
-
filled = filled_list[min(self.mark_num, len(filled_list) - 1)] # 随机选择填充字符
|
261
|
+
filled = self.filled
|
261
262
|
empty = " "
|
262
263
|
# 为其他信息保留更多空间
|
263
264
|
max_width = max(10, width - 60) # 至少保留10个字符的进度条
|
@@ -363,7 +364,10 @@ class ColorProgressBar:
|
|
363
364
|
self._file.write(f"{line}\n")
|
364
365
|
elif self._is_terminal:
|
365
366
|
# 标准终端环境,覆盖同一行
|
366
|
-
self.
|
367
|
+
if self.next_line:
|
368
|
+
self._file.write(f"\r{line}\n")
|
369
|
+
else:
|
370
|
+
self._file.write(f"\r{line}")
|
367
371
|
else:
|
368
372
|
# 非交互式环境,仅在完成时输出
|
369
373
|
if self.task.finished:
|
@@ -395,7 +399,7 @@ class ColorProgressBar:
|
|
395
399
|
|
396
400
|
finally:
|
397
401
|
# 完成后进行清理
|
398
|
-
if self._is_terminal and not self._is_jupyter:
|
402
|
+
if self._is_terminal and not self._is_jupyter and not self.next_line:
|
399
403
|
self._file.write("\n")
|
400
404
|
self._file.flush()
|
401
405
|
|
@@ -406,28 +410,46 @@ class ColorProgressBar:
|
|
406
410
|
return [to_hex(cmap(i)) for i in np.linspace(0, 1, n)]
|
407
411
|
|
408
412
|
|
413
|
+
def cpbar(
|
414
|
+
iterable,
|
415
|
+
description="Working...",
|
416
|
+
total=None,
|
417
|
+
completed=0,
|
418
|
+
color="cyan",
|
419
|
+
cmap=None,
|
420
|
+
update_interval=0.1,
|
421
|
+
bar_length=None,
|
422
|
+
speed_estimate_period=30.0,
|
423
|
+
next_line=False,
|
424
|
+
):
|
425
|
+
"""便捷函数,返回 ColorProgressBar 对象"""
|
426
|
+
return ColorProgressBar(
|
427
|
+
iterable=iterable,
|
428
|
+
description=description,
|
429
|
+
total=total,
|
430
|
+
completed=completed,
|
431
|
+
color=color,
|
432
|
+
cmap=cmap,
|
433
|
+
update_interval=update_interval,
|
434
|
+
bar_length=bar_length,
|
435
|
+
speed_estimate_period=speed_estimate_period,
|
436
|
+
next_line=next_line,
|
437
|
+
)
|
438
|
+
|
439
|
+
|
409
440
|
# 验证示例
|
410
441
|
if __name__ == "__main__":
|
411
|
-
for _ in
|
412
|
-
|
442
|
+
for _ in cpbar(range(20), description="Diverging:", cmap="diverging_1", next_line=True):
|
443
|
+
print("Processing...")
|
413
444
|
time.sleep(0.1)
|
414
445
|
|
415
|
-
for _ in ColorProgressBar(range(
|
416
|
-
time.sleep(0.1)
|
417
|
-
|
418
|
-
for _ in ColorProgressBar(range(100), description="Viridis:", cmap="viridis"):
|
446
|
+
for _ in ColorProgressBar(range(20), description="Viridis:", cmap="viridis"):
|
419
447
|
time.sleep(0.1)
|
420
448
|
|
421
449
|
# 使用自定义渐变色
|
422
450
|
for _ in ColorProgressBar(range(50), description="Custom_cmap:", cmap=["#FF0000", "#0000FF"]):
|
423
451
|
time.sleep(0.1)
|
424
452
|
|
425
|
-
for _ in ColorProgressBar(range(50), description="Default:"):
|
426
|
-
time.sleep(0.1)
|
427
|
-
|
428
|
-
for _ in ColorProgressBar(range(50), description="Custom_color:", color="#FF00FF"):
|
429
|
-
time.sleep(0.1)
|
430
|
-
|
431
453
|
# 测试无法获取长度的迭代器
|
432
454
|
def infinite_generator():
|
433
455
|
i = 0
|
@@ -1097,7 +1097,7 @@ def download(var, time_s, time_e=None, lon_min=0, lon_max=359.92, lat_min=-80, l
|
|
1097
1097
|
Returns:
|
1098
1098
|
None
|
1099
1099
|
"""
|
1100
|
-
from oafuncs.
|
1100
|
+
from oafuncs.oa_tool import pbar
|
1101
1101
|
from oafuncs.oa_cmap import get as get_cmap
|
1102
1102
|
|
1103
1103
|
_get_initial_data()
|
@@ -1,21 +1,8 @@
|
|
1
|
-
|
2
|
-
# coding=utf-8
|
3
|
-
"""
|
4
|
-
Author: Liu Kun && 16031215@qq.com
|
5
|
-
Date: 2025-04-04 20:17:42
|
6
|
-
LastEditors: Liu Kun && 16031215@qq.com
|
7
|
-
LastEditTime: 2025-04-04 20:17:45
|
8
|
-
FilePath: \\Python\\My_Funcs\\OAFuncs\\oafuncs\\oa_tool.py
|
9
|
-
Description:
|
10
|
-
EditPlatform: vscode
|
11
|
-
ComputerInfo: XPS 15 9510
|
12
|
-
SystemInfo: Windows 11
|
13
|
-
Python Version: 3.12
|
14
|
-
"""
|
15
|
-
from typing import Iterable
|
1
|
+
from typing import Any, Iterable, List, Optional, Union
|
16
2
|
|
17
3
|
__all__ = ["PEx", "email", "pbar"]
|
18
4
|
|
5
|
+
|
19
6
|
class PEx:
|
20
7
|
"""
|
21
8
|
PEx 封装了 ParallelExecutor,
|
@@ -37,7 +24,7 @@ class PEx:
|
|
37
24
|
|
38
25
|
def __init__(self, *args, **kwargs):
|
39
26
|
"""
|
40
|
-
初始化 PEx 实例,内部创建一个 ParallelExecutor
|
27
|
+
初始化 PEx 实例,内部创建一个 ParallelExecutor 实例
|
41
28
|
|
42
29
|
参数:
|
43
30
|
*args: 传递给 ParallelExecutor 的位置参数。
|
@@ -47,7 +34,7 @@ class PEx:
|
|
47
34
|
|
48
35
|
def __getattr__(self, attr):
|
49
36
|
"""
|
50
|
-
将所有未定义的属性访问委托给内部的 ParallelExecutor
|
37
|
+
将所有未定义的属性访问委托给内部的 ParallelExecutor 实例
|
51
38
|
|
52
39
|
参数:
|
53
40
|
attr (str): 要访问的属性名称。
|
@@ -58,26 +45,36 @@ class PEx:
|
|
58
45
|
return getattr(self.executor, attr)
|
59
46
|
|
60
47
|
|
61
|
-
def email(title="Title", content=None, send_to="
|
48
|
+
def email(title="Title", content=None, send_to="10001@qq.com"):
|
62
49
|
from ._script.email import send
|
50
|
+
|
63
51
|
send(title, content, send_to)
|
64
52
|
|
65
53
|
|
66
|
-
def pbar(
|
67
|
-
|
68
|
-
|
69
|
-
:
|
70
|
-
:
|
71
|
-
|
72
|
-
|
73
|
-
:
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
for i in pbar(range(100), prefix="Processing", color="green", cmap="viridis"):
|
79
|
-
sleep(0.1)
|
80
|
-
"""
|
54
|
+
def pbar(
|
55
|
+
iterable: Iterable=range(100),
|
56
|
+
description: str = "Working...",
|
57
|
+
total: Optional[float] = None,
|
58
|
+
completed: float = 0,
|
59
|
+
color: Any = "cyan",
|
60
|
+
cmap: Union[str, List[str], None] = None,
|
61
|
+
update_interval: float = 0.1,
|
62
|
+
bar_length: Optional[int] = None,
|
63
|
+
speed_estimate_period: float = 30.0,
|
64
|
+
next_line: bool = False,
|
65
|
+
):
|
81
66
|
from ._script.cprogressbar import ColorProgressBar
|
82
67
|
|
83
|
-
|
68
|
+
"""便捷函数,返回 ColorProgressBar 对象"""
|
69
|
+
return ColorProgressBar(
|
70
|
+
iterable=iterable,
|
71
|
+
description=description,
|
72
|
+
total=total,
|
73
|
+
completed=completed,
|
74
|
+
color=color,
|
75
|
+
cmap=cmap,
|
76
|
+
update_interval=update_interval,
|
77
|
+
bar_length=bar_length,
|
78
|
+
speed_estimate_period=speed_estimate_period,
|
79
|
+
next_line=next_line,
|
80
|
+
)
|
@@ -18,7 +18,7 @@ URL = "https://github.com/Industry-Pays/OAFuncs"
|
|
18
18
|
EMAIL = "liukun0312@stu.ouc.edu.cn"
|
19
19
|
AUTHOR = "Kun Liu"
|
20
20
|
REQUIRES_PYTHON = ">=3.9.0" # 2025/03/13
|
21
|
-
VERSION = "0.0.97.
|
21
|
+
VERSION = "0.0.97.16" # 下次用98.0,98.1已经被用过了
|
22
22
|
|
23
23
|
# What packages are required for this module to be executed?
|
24
24
|
REQUIRED = [
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|