stock-tracker

This commit is contained in:
C菌
2026-07-04 00:17:11 +08:00
commit 6087341a48
6463 changed files with 1929869 additions and 0 deletions
@@ -0,0 +1,27 @@
def get_tqdm(enable: bool = True):
"""
返回适用于当前环境的 tqdm 对象。
Args:
enable (bool): 是否启用进度条。默认为 True。
Returns:
tqdm 对象。
"""
if not enable:
# 如果进度条被禁用,返回一个不显示进度条的 tqdm 对象
return lambda iterable, *args, **kwargs: iterable
try:
# 尝试检查是否在 jupyter notebook 环境中,有利于退出进度条
# noinspection PyUnresolvedReferences
shell = get_ipython().__class__.__name__
if shell == "ZMQInteractiveShell":
from tqdm.notebook import tqdm
else:
from tqdm import tqdm
except (NameError, ImportError):
# 如果不在 Jupyter 环境中,就使用标准 tqdm
from tqdm import tqdm
return tqdm