oafuncs 0.0.97.15__py3-none-any.whl → 0.0.97.17__py3-none-any.whl
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/_script/cprogressbar.py +42 -20
- oafuncs/_script/netcdf_modify.py +10 -2
- oafuncs/oa_cmap.py +211 -95
- oafuncs/oa_data.py +157 -218
- oafuncs/oa_date.py +71 -37
- oafuncs/oa_down/hycom_3hourly.py +209 -320
- oafuncs/oa_down/hycom_3hourly_20250407.py +1295 -0
- oafuncs/oa_down/idm.py +4 -4
- oafuncs/oa_draw.py +224 -124
- oafuncs/oa_file.py +279 -333
- oafuncs/oa_help.py +10 -0
- oafuncs/oa_nc.py +197 -164
- oafuncs/oa_python.py +51 -25
- oafuncs/oa_tool.py +84 -48
- {oafuncs-0.0.97.15.dist-info → oafuncs-0.0.97.17.dist-info}/METADATA +1 -1
- {oafuncs-0.0.97.15.dist-info → oafuncs-0.0.97.17.dist-info}/RECORD +20 -19
- /oafuncs/_script/{replace_file_concent.py → replace_file_content.py} +0 -0
- {oafuncs-0.0.97.15.dist-info → oafuncs-0.0.97.17.dist-info}/WHEEL +0 -0
- {oafuncs-0.0.97.15.dist-info → oafuncs-0.0.97.17.dist-info}/licenses/LICENSE.txt +0 -0
- {oafuncs-0.0.97.15.dist-info → oafuncs-0.0.97.17.dist-info}/top_level.txt +0 -0
oafuncs/oa_tool.py
CHANGED
@@ -1,83 +1,119 @@
|
|
1
|
-
|
2
|
-
|
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
|
2
|
+
|
3
|
+
from rich import print
|
16
4
|
|
17
5
|
__all__ = ["PEx", "email", "pbar"]
|
18
6
|
|
7
|
+
|
19
8
|
class PEx:
|
20
9
|
"""
|
21
|
-
PEx
|
22
|
-
|
10
|
+
PEx wraps ParallelExecutor and delegates all its methods,
|
11
|
+
allowing direct calls to PEx methods to achieve the same effect as ParallelExecutor.
|
23
12
|
|
24
|
-
|
25
|
-
#
|
13
|
+
Example:
|
14
|
+
# Create a PEx instance
|
26
15
|
executor = PEx(max_workers=4)
|
27
16
|
|
28
|
-
#
|
17
|
+
# Use the run method to execute parallel tasks
|
29
18
|
result = executor.run(lambda x: x * x, [(i,) for i in range(5)])
|
30
|
-
print(result) #
|
19
|
+
print(result) # Output: [0, 1, 4, 9, 16]
|
31
20
|
"""
|
32
21
|
|
33
22
|
try:
|
34
23
|
from ._script.parallel import ParallelExecutor
|
35
24
|
except ImportError:
|
36
|
-
raise ImportError("ParallelExecutor could not be imported. Ensure the module '_script.parallel' exists and is accessible.")
|
25
|
+
raise ImportError("[red]ParallelExecutor could not be imported. Ensure the module '_script.parallel' exists and is accessible.[/red]")
|
37
26
|
|
38
|
-
def __init__(self, *args, **kwargs):
|
27
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
39
28
|
"""
|
40
|
-
|
29
|
+
Initialize a PEx instance, internally creating a ParallelExecutor instance.
|
41
30
|
|
42
|
-
|
43
|
-
*args:
|
44
|
-
**kwargs:
|
31
|
+
Args:
|
32
|
+
*args: Positional arguments passed to ParallelExecutor.
|
33
|
+
**kwargs: Keyword arguments passed to ParallelExecutor.
|
45
34
|
"""
|
46
35
|
self.executor = self.ParallelExecutor(*args, **kwargs)
|
47
36
|
|
48
|
-
def __getattr__(self, attr):
|
37
|
+
def __getattr__(self, attr: str) -> Any:
|
49
38
|
"""
|
50
|
-
|
39
|
+
Delegate all undefined attribute access to the internal ParallelExecutor instance.
|
51
40
|
|
52
|
-
|
53
|
-
attr (str):
|
41
|
+
Args:
|
42
|
+
attr (str): The name of the attribute to access.
|
54
43
|
|
55
|
-
|
56
|
-
|
44
|
+
Returns:
|
45
|
+
Any: The value of the corresponding attribute.
|
57
46
|
"""
|
58
47
|
return getattr(self.executor, attr)
|
59
48
|
|
60
49
|
|
61
|
-
def email(title="Title", content=None, send_to="
|
50
|
+
def email(title: str = "Title", content: Optional[str] = None, send_to: str = "10001@qq.com") -> None:
|
51
|
+
"""
|
52
|
+
Send an email using the specified title, content, and recipient.
|
53
|
+
|
54
|
+
Args:
|
55
|
+
title (str): The title of the email. Defaults to "Title".
|
56
|
+
content (Optional[str]): The content of the email. Defaults to None.
|
57
|
+
send_to (str): The recipient's email address. Defaults to "10001@qq.com".
|
58
|
+
"""
|
62
59
|
from ._script.email import send
|
60
|
+
|
61
|
+
print(f"[green]Sending email to {send_to} with title: {title}[/green]")
|
63
62
|
send(title, content, send_to)
|
64
63
|
|
65
64
|
|
66
|
-
def pbar(
|
65
|
+
def pbar(
|
66
|
+
iterable: Iterable = range(100),
|
67
|
+
description: str = "Working...",
|
68
|
+
total: Optional[float] = None,
|
69
|
+
completed: float = 0,
|
70
|
+
color: Any = "cyan",
|
71
|
+
cmap: Union[str, List[str], None] = None,
|
72
|
+
update_interval: float = 0.1,
|
73
|
+
bar_length: Optional[int] = None,
|
74
|
+
speed_estimate_period: float = 30.0,
|
75
|
+
next_line: bool = False,
|
76
|
+
) -> Any:
|
67
77
|
"""
|
68
|
-
|
69
|
-
|
70
|
-
:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
78
|
+
Convenience function to return a ColorProgressBar object.
|
79
|
+
|
80
|
+
Args:
|
81
|
+
iterable (Iterable): The iterable to track progress for. Defaults to range(100).
|
82
|
+
description (str): Description text for the progress bar. Defaults to "Working...".
|
83
|
+
total (Optional[float]): Total number of iterations. Defaults to None.
|
84
|
+
completed (float): Number of completed iterations. Defaults to 0.
|
85
|
+
color (Any): Color of the progress bar. Defaults to "cyan".
|
86
|
+
cmap (Union[str, List[str], None]): Color map for the progress bar. Defaults to None.
|
87
|
+
update_interval (float): Interval for updating the progress bar. Defaults to 0.1.
|
88
|
+
bar_length (Optional[int]): Length of the progress bar. Defaults to None.
|
89
|
+
speed_estimate_period (float): Period for speed estimation. Defaults to 30.0.
|
90
|
+
next_line (bool): Whether to move to the next line after completion. Defaults to False.
|
91
|
+
|
92
|
+
Returns:
|
93
|
+
Any: An instance of ColorProgressBar.
|
94
|
+
|
95
|
+
Example:
|
96
|
+
>>> for i in pbar(range(10), description="Processing"):
|
97
|
+
... time.sleep(0.1)
|
98
|
+
>>> for i in pbar(range(10), description="Processing", color="green"):
|
99
|
+
... time.sleep(0.1)
|
100
|
+
>>> for i in pbar(range(10), description="Processing", cmap=["red", "green"]):
|
101
|
+
... time.sleep(0.1)
|
102
|
+
>>> for i in pbar(range(10), description="Processing", cmap="viridis"):
|
103
|
+
... time.sleep(0.1)
|
80
104
|
"""
|
81
105
|
from ._script.cprogressbar import ColorProgressBar
|
82
106
|
|
83
|
-
|
107
|
+
print(f"[blue]{description}[/blue]")
|
108
|
+
return ColorProgressBar(
|
109
|
+
iterable=iterable,
|
110
|
+
description=description,
|
111
|
+
total=total,
|
112
|
+
completed=completed,
|
113
|
+
color=color,
|
114
|
+
cmap=cmap,
|
115
|
+
update_interval=update_interval,
|
116
|
+
bar_length=bar_length,
|
117
|
+
speed_estimate_period=speed_estimate_period,
|
118
|
+
next_line=next_line,
|
119
|
+
)
|
@@ -1,28 +1,29 @@
|
|
1
1
|
oafuncs/__init__.py,sha256=T_-VtnWWllV3Q91twT5Yt2sUapeA051QbPNnBxmg9nw,1456
|
2
|
-
oafuncs/oa_cmap.py,sha256=
|
3
|
-
oafuncs/oa_data.py,sha256=
|
4
|
-
oafuncs/oa_date.py,sha256=
|
5
|
-
oafuncs/oa_draw.py,sha256=
|
6
|
-
oafuncs/oa_file.py,sha256=
|
7
|
-
oafuncs/oa_help.py,sha256=
|
8
|
-
oafuncs/oa_nc.py,sha256=
|
9
|
-
oafuncs/oa_python.py,sha256=
|
10
|
-
oafuncs/oa_tool.py,sha256=
|
2
|
+
oafuncs/oa_cmap.py,sha256=DimWT4Bg7uE5Lx8hSw1REp7whpsR2pFRStAwk1cowEM,11494
|
3
|
+
oafuncs/oa_data.py,sha256=0AbQ8_7vf9ecZaui6hmUjubkWRJxs4TGcdhJaPdbmP8,10958
|
4
|
+
oafuncs/oa_date.py,sha256=KqU-bHtC74hYsf6VgiA3i2vI__q_toOVR-whFy4cYP8,5523
|
5
|
+
oafuncs/oa_draw.py,sha256=9hchfs7kyBo_On1FA5jliSoAwpsjEXNUIC9C20D9ugw,15050
|
6
|
+
oafuncs/oa_file.py,sha256=goF5iRXJFFCIKhIjlkCnYYt0EYlJb_4r8AeYNZ0-SOk,16209
|
7
|
+
oafuncs/oa_help.py,sha256=_4AZgRDq5Or0vauNvq5IDDHIBoBfdOQtzak-mG1wwAw,4537
|
8
|
+
oafuncs/oa_nc.py,sha256=StkcZZYo6FKANuPcq7OaIKoBKj5HuFwHsrZRVKa4ULw,10489
|
9
|
+
oafuncs/oa_python.py,sha256=NkopwkYFGSEuVljnTBvXCl6o2CeyRNBqRXSsUl3euEE,5192
|
10
|
+
oafuncs/oa_tool.py,sha256=8y0X3KXNLbYchr5hBHCwhdsA_1VDEnzsZVqcM5sNeog,4484
|
11
11
|
oafuncs/_data/OAFuncs.png,sha256=y1_x-mUP3gFjcy6m8FqfvQO_HgjzPhQKfXjnSHjslZE,3436152
|
12
12
|
oafuncs/_data/hycom_3hourly.png,sha256=azt_uPcXtl_8CSKRLLPCIf5pPrcxMiOzvoFQnwb0zUo,12411415
|
13
|
-
oafuncs/_script/cprogressbar.py,sha256=
|
13
|
+
oafuncs/_script/cprogressbar.py,sha256=wRU3SFPFtMI7ER26tTzg223kVKNo5RDWE9CzdIgUsuE,15771
|
14
14
|
oafuncs/_script/email.py,sha256=lL4HGKrr524-g0xLlgs-4u7x4-u7DtgNoD9AL8XJKj4,3058
|
15
15
|
oafuncs/_script/netcdf_merge.py,sha256=_EPF9Xj4HOVC9sZpi1lt62-Aq6pMlgsgwaajEBLhW6g,5092
|
16
|
-
oafuncs/_script/netcdf_modify.py,sha256=
|
16
|
+
oafuncs/_script/netcdf_modify.py,sha256=sGRUYNhfGgf9JV70rnBzw3bzuTRSXzBTL_RMDnDPeLQ,4552
|
17
17
|
oafuncs/_script/netcdf_write.py,sha256=KZ0ui2nvTujAciLKx4bwQHLEkH1R3P8hCzd7BysJ0D4,5288
|
18
18
|
oafuncs/_script/parallel.py,sha256=FS9FgaByq2yb9j6nL-Y0xP1VLvp4USMLBFMRsJDoqeQ,21848
|
19
19
|
oafuncs/_script/parallel_example_usage.py,sha256=uLvE7iwkMn9Cyq6-wk5_RpbQk7PXM9d16-26lTknW9s,2646
|
20
20
|
oafuncs/_script/plot_dataset.py,sha256=zkSEnO_-biyagorwWXPoihts_cwuvripzEt-l9bHJ2E,13989
|
21
|
-
oafuncs/_script/
|
21
|
+
oafuncs/_script/replace_file_content.py,sha256=eCFZjnZcwyRvy6b4mmIfBna-kylSZTyJRfgXd6DdCjk,5982
|
22
22
|
oafuncs/oa_down/User_Agent-list.txt,sha256=pazxSip8_lphEBOPHG902zmIBUg8sBKXgmqp_g6j_E4,661062
|
23
23
|
oafuncs/oa_down/__init__.py,sha256=kRX5eTUCbAiz3zTaQM1501paOYS_3fizDN4Pa0mtNUA,585
|
24
|
-
oafuncs/oa_down/hycom_3hourly.py,sha256=
|
25
|
-
oafuncs/oa_down/
|
24
|
+
oafuncs/oa_down/hycom_3hourly.py,sha256=F3g14LJG3IfXO7gtH5nOVLvz68frVmtIypikZYDrc3M,52909
|
25
|
+
oafuncs/oa_down/hycom_3hourly_20250407.py,sha256=DQd_NmQgmSqu7jsrfpDB7k23mkUEy9kyWs-dLUg7GDw,64472
|
26
|
+
oafuncs/oa_down/idm.py,sha256=gZHyUJMyd9zgzZGksI-BuNuouK_JGjxQZniUgUFENPs,1801
|
26
27
|
oafuncs/oa_down/literature.py,sha256=2bF9gSKQbzcci9LcKE81j8JEjIJwON7jbwQB3gDDA3E,11331
|
27
28
|
oafuncs/oa_down/test_ua.py,sha256=0IQq3NjqfNr7KkyjS_U-a4mYu-r-E7gzawwo4IfEa6Y,10851
|
28
29
|
oafuncs/oa_down/user_agent.py,sha256=TsPcAxFmMTYAEHRFjurI1bQBJfDhcA70MdHoUPwQmks,785
|
@@ -35,8 +36,8 @@ oafuncs/oa_sign/__init__.py,sha256=QKqTFrJDFK40C5uvk48GlRRbGFzO40rgkYwu6dYxatM,5
|
|
35
36
|
oafuncs/oa_sign/meteorological.py,sha256=8091SHo2L8kl4dCFmmSH5NGVHDku5i5lSiLEG5DLnOQ,6489
|
36
37
|
oafuncs/oa_sign/ocean.py,sha256=xrW-rWD7xBWsB5PuCyEwQ1Q_RDKq2KCLz-LOONHgldU,5932
|
37
38
|
oafuncs/oa_sign/scientific.py,sha256=a4JxOBgm9vzNZKpJ_GQIQf7cokkraV5nh23HGbmTYKw,5064
|
38
|
-
oafuncs-0.0.97.
|
39
|
-
oafuncs-0.0.97.
|
40
|
-
oafuncs-0.0.97.
|
41
|
-
oafuncs-0.0.97.
|
42
|
-
oafuncs-0.0.97.
|
39
|
+
oafuncs-0.0.97.17.dist-info/licenses/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
|
40
|
+
oafuncs-0.0.97.17.dist-info/METADATA,sha256=FtLHP3YreXpw-Zz4d-jjrQYXJ3MxSr5UcSjvpGsAEi0,4226
|
41
|
+
oafuncs-0.0.97.17.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
42
|
+
oafuncs-0.0.97.17.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
|
43
|
+
oafuncs-0.0.97.17.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|