feat:增加分析进度接口
This commit is contained in:
+18
-1
@@ -1,6 +1,6 @@
|
||||
"""数据文件各环节共用的异常、上限和警告文案的写法"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Callable, Sequence
|
||||
|
||||
# 每张表的数据行数上限
|
||||
MAX_TABLE_ROWS = 1_000_000
|
||||
@@ -37,3 +37,20 @@ def rows_exceeded(sheet: str | None) -> DataFileError:
|
||||
return DataFileError(
|
||||
422, f"{where(sheet)}超过 {MAX_TABLE_ROWS // 10_000} 万行,请拆分后上传"
|
||||
)
|
||||
|
||||
|
||||
# 解析进度的回调:参数是当前环节内已完成的比例,0 到 1
|
||||
Reporter = Callable[[float], None]
|
||||
|
||||
|
||||
def no_report(fraction: float) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def scaled(report: Reporter, start: float, end: float) -> Reporter:
|
||||
"""把环节内的进度映射到上一级进度的 start 到 end 之间"""
|
||||
|
||||
def inner(fraction: float) -> None:
|
||||
report(start + (end - start) * min(max(fraction, 0.0), 1.0))
|
||||
|
||||
return inner
|
||||
|
||||
Reference in New Issue
Block a user