funcguard 0.2.0__py3-none-any.whl → 0.2.1__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.
Potentially problematic release.
This version of funcguard might be problematic. Click here for more details.
- funcguard/time_utils.py +21 -13
- {funcguard-0.2.0.dist-info → funcguard-0.2.1.dist-info}/METADATA +1 -1
- {funcguard-0.2.0.dist-info → funcguard-0.2.1.dist-info}/RECORD +6 -6
- {funcguard-0.2.0.dist-info → funcguard-0.2.1.dist-info}/LICENSE +0 -0
- {funcguard-0.2.0.dist-info → funcguard-0.2.1.dist-info}/WHEEL +0 -0
- {funcguard-0.2.0.dist-info → funcguard-0.2.1.dist-info}/top_level.txt +0 -0
funcguard/time_utils.py
CHANGED
|
@@ -20,16 +20,23 @@ def time_log(message, i = 0, max_num = 0, s_time = None, start_from = 0 , return
|
|
|
20
20
|
"""
|
|
21
21
|
now = datetime.now( timezone( timedelta( hours = 8 ) ) )
|
|
22
22
|
time_str = "{:02d}:{:02d}:{:02d}".format( now.hour, now.minute, now.second )
|
|
23
|
-
progress_info = ""
|
|
23
|
+
progress_info = eta_time_info = etr_time_info = ""
|
|
24
24
|
if i < 2 or max_num < 2 :
|
|
25
|
-
|
|
25
|
+
if return_field in ["end_time", "remaining_time"] :
|
|
26
|
+
return ""
|
|
27
|
+
else:
|
|
28
|
+
print( time_str + " " + message )
|
|
26
29
|
|
|
27
30
|
else :
|
|
28
31
|
# 根据start_from参数计算实际处理的项目数
|
|
29
32
|
process_item = i + 1 if start_from == 0 else i
|
|
30
33
|
progress_info = "{}/{}".format( process_item, max_num )
|
|
31
34
|
# 检查是否应该显示预计完成时间和剩余时间
|
|
32
|
-
|
|
35
|
+
# 当return_field为"end_time"或"remaining_time"时,每次都计算时间
|
|
36
|
+
# 否则只在每10个处理一次时计算
|
|
37
|
+
should_calculate_time = (return_field in ["end_time", "remaining_time"] and process_item < max_num ) or (process_item % 10 == 0 and s_time is not None and process_item < max_num)
|
|
38
|
+
|
|
39
|
+
if should_calculate_time and s_time is not None and process_item < max_num:
|
|
33
40
|
duration = now - s_time
|
|
34
41
|
ev_duration = duration / process_item # 每项平均耗时
|
|
35
42
|
remaining_items = max_num - process_item
|
|
@@ -37,16 +44,17 @@ def time_log(message, i = 0, max_num = 0, s_time = None, start_from = 0 , return
|
|
|
37
44
|
end_time = now + time_left
|
|
38
45
|
end_time_str = end_time.strftime( "%Y-%m-%d %H:%M" )
|
|
39
46
|
remaining_time_str = str( timedelta( seconds = int( time_left.total_seconds() ) ) )
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
eta_time_info = f"eta {end_time_str}"
|
|
48
|
+
etr_time_info = f"etr {remaining_time_str}"
|
|
49
|
+
progress_info = progress_info + f" ( {eta_time_info} {etr_time_info} )"
|
|
50
|
+
|
|
51
|
+
# Estimated Time of Arrival(预计完成/到达时间)
|
|
52
|
+
if return_field == "end_time" :
|
|
53
|
+
return eta_time_info
|
|
54
|
+
|
|
55
|
+
# Estimated Time Remaining(预计剩余时间)
|
|
56
|
+
elif return_field == "remaining_time" :
|
|
57
|
+
return etr_time_info
|
|
50
58
|
|
|
51
59
|
print( time_str + " " + message + " " + progress_info )
|
|
52
60
|
return progress_info
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
funcguard/__init__.py,sha256=XdbsQ5p2wG9YK9CoI7xWc6UEzFuuOuR_r2dov6D_oiE,469
|
|
2
2
|
funcguard/core.py,sha256=-rFRkE-udxM0wxlcv9Qi_yIQBRdVrGgwza-LYQsVRLg,3632
|
|
3
3
|
funcguard/printer.py,sha256=zjCPPkBrz_D1z8563Vi-raxEti5kLSwahSoqYuP20eg,2455
|
|
4
|
-
funcguard/time_utils.py,sha256=
|
|
4
|
+
funcguard/time_utils.py,sha256=kFwrrLVHIi_UYmSxRzXLmgGUM_hURJ-xoCPa_Set3z4,7268
|
|
5
5
|
funcguard/tools.py,sha256=pw6QCi8BAOTkHKhG3sxqfU3pYzST08YjxTiPvK-SWnU,1972
|
|
6
6
|
tests/__init__.py,sha256=VW6FdWdSC_PL3zEtpkRQfUMf6yVD2OfwtSds82jawTs,26
|
|
7
|
-
funcguard-0.2.
|
|
8
|
-
funcguard-0.2.
|
|
9
|
-
funcguard-0.2.
|
|
10
|
-
funcguard-0.2.
|
|
11
|
-
funcguard-0.2.
|
|
7
|
+
funcguard-0.2.1.dist-info/LICENSE,sha256=jgOquECfjiXp5xXQ2zuzItDr4XDBLan-bIzIXl1lS4Y,1064
|
|
8
|
+
funcguard-0.2.1.dist-info/METADATA,sha256=fKt8L1Yj9v-CncSW_8GZ-CdI89WY-qj2aH21X1yiuGY,10598
|
|
9
|
+
funcguard-0.2.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
10
|
+
funcguard-0.2.1.dist-info/top_level.txt,sha256=7wL9mWT062DttKNO7Wi1wYWTZilR2AOPRO0rE3gvtB4,16
|
|
11
|
+
funcguard-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|