bcmd 0.0.37__py3-none-any.whl → 0.0.38__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 bcmd might be problematic. Click here for more details.

bcmd/tasks/math.py CHANGED
@@ -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(..., help='原始数值'),
47
- new: float = typer.Argument(..., help='新数值'),
47
+ old: float = typer.Argument(nan, help='原始数值'),
48
+ new: float = typer.Argument(nan, help='新数值'),
48
49
  ):
49
- '计算增长率,例子:beni math increase 123 456'
50
- value = (new - old) / old
51
- if value > 0:
52
- valueStr = bcolor.red(f'{value*100:+,.3f}%')
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
- valueStr = bcolor.green(f'{value*100:+,.3f}%')
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()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bcmd
3
- Version: 0.0.37
3
+ Version: 0.0.38
4
4
  Summary: Commands for Beni
5
5
  Author-email: Beni Mang <benimang@126.com>
6
6
  Maintainer-email: Beni Mang <benimang@126.com>
@@ -4,14 +4,14 @@ bcmd/tasks/__init__.py,sha256=vEBrd2_BY35FgRIV2ZB4xXbx-Zgbd6tfAdm4OUjKVys,187
4
4
  bcmd/tasks/bin.py,sha256=SqKvGWesoigM0zoQZ8YO84zfCGuPV0CnpDmPHODL9Fo,3546
5
5
  bcmd/tasks/json.py,sha256=hO3-CGjtqB7QORVG5gS-CnrF90SZ3UqYHIpdsV_-9QQ,556
6
6
  bcmd/tasks/lib.py,sha256=w85LjJh7ATFoEtUiBL5qMWfMM412YMwkZd8hMfa3wVo,2520
7
- bcmd/tasks/math.py,sha256=-5gZ8BLT9SBwu5RwCT-8RN6mFOLCi0gUnazwxRsnHT4,3525
7
+ bcmd/tasks/math.py,sha256=VlxRvqi2E7vN-_z4jmZV_GSPoJdPJsVP2_qm75Y7juA,4317
8
8
  bcmd/tasks/mirror.py,sha256=5eqOcE6CwNGrSqHqXukIfzSWmnqRKi3gGGv2OIlYNw8,1429
9
9
  bcmd/tasks/proxy.py,sha256=DLIklFMRWUNBKE_0i8pciQdBE5bvAHCejXzzIYp4Ng8,641
10
10
  bcmd/tasks/task.py,sha256=_ROF6vQGdqx6Tm_USelI4x_FSlc2dCsjY9yeEK0EPog,7260
11
11
  bcmd/tasks/time.py,sha256=AuGThsQXMIrp9p8MxyqYpda4uvqveFQJM4rSqCK9Nk8,2567
12
12
  bcmd/tasks/venv.py,sha256=OHttHc2MpTjvWDeNJQscRDnA-ekz79O-_Xv0O92a4FA,3601
13
- bcmd-0.0.37.dist-info/METADATA,sha256=mzeI1JI8ZnMytxFUA2JD1y5V2-ShYpzcy4qNh1DZ8Dc,664
14
- bcmd-0.0.37.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
15
- bcmd-0.0.37.dist-info/entry_points.txt,sha256=rHJrP6KEQpB-YaQqDFzEL2v88r03rxSfnzAayRvAqHU,39
16
- bcmd-0.0.37.dist-info/top_level.txt,sha256=-KrvhhtBcYsm4XhcjQvEcFbBB3VXeep7d3NIfDTrXKQ,5
17
- bcmd-0.0.37.dist-info/RECORD,,
13
+ bcmd-0.0.38.dist-info/METADATA,sha256=j0wEl-IBrxAPylge0W5JdfDcCmJoTX8ZeAvCS61K-ow,664
14
+ bcmd-0.0.38.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
15
+ bcmd-0.0.38.dist-info/entry_points.txt,sha256=rHJrP6KEQpB-YaQqDFzEL2v88r03rxSfnzAayRvAqHU,39
16
+ bcmd-0.0.38.dist-info/top_level.txt,sha256=-KrvhhtBcYsm4XhcjQvEcFbBB3VXeep7d3NIfDTrXKQ,5
17
+ bcmd-0.0.38.dist-info/RECORD,,
File without changes