bcmd 0.0.37__tar.gz → 0.0.38__tar.gz
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 bcmd might be problematic. Click here for more details.
- {bcmd-0.0.37 → bcmd-0.0.38}/PKG-INFO +1 -1
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/math.py +40 -17
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd.egg-info/PKG-INFO +1 -1
- {bcmd-0.0.37 → bcmd-0.0.38}/pyproject.toml +1 -1
- {bcmd-0.0.37 → bcmd-0.0.38}/README.md +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/__init__.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/main.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/__init__.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/bin.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/json.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/lib.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/mirror.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/proxy.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/task.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/time.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd/tasks/venv.py +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd.egg-info/SOURCES.txt +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd.egg-info/dependency_links.txt +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd.egg-info/entry_points.txt +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd.egg-info/requires.txt +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/bcmd.egg-info/top_level.txt +0 -0
- {bcmd-0.0.37 → bcmd-0.0.38}/setup.cfg +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from math import nan
|
|
1
2
|
from typing import Final
|
|
2
3
|
|
|
3
4
|
import typer
|
|
@@ -43,25 +44,47 @@ async def scale(
|
|
|
43
44
|
@app.command()
|
|
44
45
|
@bfunc.syncCall
|
|
45
46
|
async def increase(
|
|
46
|
-
old: float = typer.Argument(
|
|
47
|
-
new: float = typer.Argument(
|
|
47
|
+
old: float = typer.Argument(nan, help='原始数值'),
|
|
48
|
+
new: float = typer.Argument(nan, help='新数值'),
|
|
48
49
|
):
|
|
49
|
-
'
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
'''
|
|
51
|
+
计算增长率
|
|
52
|
+
|
|
53
|
+
例子:beni math increase 123 456
|
|
54
|
+
|
|
55
|
+
例子(连续对话):beni math increase
|
|
56
|
+
'''
|
|
57
|
+
if old is not nan and new is not nan:
|
|
58
|
+
value = (new - old) / old
|
|
59
|
+
if value > 0:
|
|
60
|
+
valueStr = bcolor.red(f'{value*100:+,.3f}%')
|
|
61
|
+
else:
|
|
62
|
+
valueStr = bcolor.green(f'{value*100:+,.3f}%')
|
|
63
|
+
table = PrettyTable(
|
|
64
|
+
title=bcolor.yellow('计算增长率'),
|
|
65
|
+
)
|
|
66
|
+
table.add_rows([
|
|
67
|
+
['旧数值', f'{old:,}'],
|
|
68
|
+
['新数值', f'{new:,}'],
|
|
69
|
+
['增长率', valueStr],
|
|
70
|
+
])
|
|
71
|
+
print()
|
|
72
|
+
print(table.get_string(header=False))
|
|
73
|
+
elif old is nan and new is nan:
|
|
74
|
+
while True:
|
|
75
|
+
print()
|
|
76
|
+
value = input('输入2个数值,空格分隔,退出输入 [exit] :').strip()
|
|
77
|
+
if value == 'exit':
|
|
78
|
+
break
|
|
79
|
+
try:
|
|
80
|
+
ary = value.split(' ')
|
|
81
|
+
ary = [float(x) for x in ary if x]
|
|
82
|
+
assert len(ary) == 2, '参数必须要2个数值'
|
|
83
|
+
increase(ary[0], ary[1])
|
|
84
|
+
except Exception as e:
|
|
85
|
+
bcolor.printRed(e)
|
|
53
86
|
else:
|
|
54
|
-
|
|
55
|
-
table = PrettyTable(
|
|
56
|
-
title=bcolor.yellow('计算增长率'),
|
|
57
|
-
)
|
|
58
|
-
table.add_rows([
|
|
59
|
-
['旧数值', f'{old:,}'],
|
|
60
|
-
['新数值', f'{new:,}'],
|
|
61
|
-
['增长率', valueStr],
|
|
62
|
-
])
|
|
63
|
-
print()
|
|
64
|
-
print(table.get_string(header=False))
|
|
87
|
+
btask.abort('参数错误,不传参数,或者传入2个数值参数')
|
|
65
88
|
|
|
66
89
|
|
|
67
90
|
@app.command()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|