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/oa_tool.py CHANGED
@@ -1,83 +1,119 @@
1
- #!/usr/bin/env python
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
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 封装了 ParallelExecutor
22
- 并将其方法全部委托,使得直接调用 PEx 的方法能够达到与 ParallelExecutor 相同的效果。
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
- # 创建 PEx 实例
13
+ Example:
14
+ # Create a PEx instance
26
15
  executor = PEx(max_workers=4)
27
16
 
28
- # 使用 run 方法执行并行任务
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) # 输出: [0, 1, 4, 9, 16]
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
- 初始化 PEx 实例,内部创建一个 ParallelExecutor 实例。
29
+ Initialize a PEx instance, internally creating a ParallelExecutor instance.
41
30
 
42
- 参数:
43
- *args: 传递给 ParallelExecutor 的位置参数。
44
- **kwargs: 传递给 ParallelExecutor 的关键字参数。
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
- 将所有未定义的属性访问委托给内部的 ParallelExecutor 实例。
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="16031215@qq.com"):
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(iterable: Iterable, description: str = "Working ...", color: str = "cyan", cmap: str = None, lupdate_interval: float = 0.1, bar_length: int = None, **kwargs) -> Iterable:
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
- :param iterable: 可迭代对象
70
- :param prefix: 进度条前缀
71
- :param color: 基础颜色
72
- :param cmap: 渐变色名称
73
- :param kwargs: 其他ColorProgressBar支持的参数
74
-
75
- example:
76
- from oafuncs.oa_data import pbar
77
- from time import sleep
78
- for i in pbar(range(100), prefix="Processing", color="green", cmap="viridis"):
79
- sleep(0.1)
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
- return ColorProgressBar(iterable=iterable, description=description, color=color, cmap=cmap, update_interval=lupdate_interval, bar_length=bar_length, **kwargs)
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oafuncs
3
- Version: 0.0.97.15
3
+ Version: 0.0.97.17
4
4
  Summary: Oceanic and Atmospheric Functions
5
5
  Home-page: https://github.com/Industry-Pays/OAFuncs
6
6
  Author: Kun Liu
@@ -1,28 +1,29 @@
1
1
  oafuncs/__init__.py,sha256=T_-VtnWWllV3Q91twT5Yt2sUapeA051QbPNnBxmg9nw,1456
2
- oafuncs/oa_cmap.py,sha256=6ggMt0ilzG_qTayIGzR57gQmViXXWYEM6S0jr1PWzNQ,6565
3
- oafuncs/oa_data.py,sha256=j_z4dOgugqyxc9STMTMZ0hKA46RyWgNtJeVWFaC8LPc,12141
4
- oafuncs/oa_date.py,sha256=MP-8eP_ASQFpHQjmB_MTSBjg46JQ1_UeLn_Ub6RSPLU,4464
5
- oafuncs/oa_draw.py,sha256=Lk0wMTyhPBgVNMWkbOLJFjajhYRB0Be4l7jx9ti3qUQ,8794
6
- oafuncs/oa_file.py,sha256=HqbB0kumd--71tMQZJUTBruNNtsGOotg77w-C7yBa0k,16524
7
- oafuncs/oa_help.py,sha256=loyzTbjU_0VpSIBvAEUA_tqxG8MVsO0xFE_2hgQ3zMw,4188
8
- oafuncs/oa_nc.py,sha256=1TIH892HmBbZKOjoW7XtP60T3lL0Tjhyq5yOWd12C1U,10423
9
- oafuncs/oa_python.py,sha256=tSRSFeTm4TicSzZeyUhlMWUy8rSrKGTRv4CqbrwfF64,4141
10
- oafuncs/oa_tool.py,sha256=8B2cyZ4l3XrWbDMkMKAlvWaiQGP_FKLKVJaqbu6G4uU,2782
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=bDIb99JqCHwIZKsrRXLfqiArTuNUuG9GyestphJM43I,15491
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=kjdAOb1iy57u8nDN-eEFTti149vfhGMY-36v-b2FtII,4224
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/replace_file_concent.py,sha256=eCFZjnZcwyRvy6b4mmIfBna-kylSZTyJRfgXd6DdCjk,5982
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=YtRgz4b7MBd2VjpPU-jIyvYn-PYQDgO20jHUMdxEyi0,64471
25
- oafuncs/oa_down/idm.py,sha256=6eKsbGZ91_187_jJawUc6lqKRdUTse6EfUJnlaSl5mo,1903
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.15.dist-info/licenses/LICENSE.txt,sha256=rMtLpVg8sKiSlwClfR9w_Dd_5WubTQgoOzE2PDFxzs4,1074
39
- oafuncs-0.0.97.15.dist-info/METADATA,sha256=x5VvCFth9kK0pT_sNmMq4xublar8wHVWkP3vJShEqdg,4226
40
- oafuncs-0.0.97.15.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
41
- oafuncs-0.0.97.15.dist-info/top_level.txt,sha256=bgC35QkXbN4EmPHEveg_xGIZ5i9NNPYWqtJqaKqTPsQ,8
42
- oafuncs-0.0.97.15.dist-info/RECORD,,
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,,