bcmd 0.0.26__tar.gz → 0.0.27__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.

@@ -1,9 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bcmd
3
- Version: 0.0.26
3
+ Version: 0.0.27
4
4
  Summary: Commands for Beni
5
- Author: Beni Mang
6
- Author-email: benimang@126.com
5
+ Author-email: Beni Mang <benimang@126.com>
7
6
  Maintainer-email: Beni Mang <benimang@126.com>
8
7
  Keywords: benimang,beni,bcmd
9
8
  Requires-Python: >=3.10
@@ -0,0 +1,94 @@
1
+ import os
2
+ from datetime import datetime
3
+ from pathlib import Path
4
+ from typing import Final
5
+
6
+ import typer
7
+ from beni import bcolor, bfile, bfunc, bstore, btable, btask
8
+ from beni.bqiniu import QiniuBucket
9
+
10
+ app: Final = btask.newSubApp('bin 工具')
11
+
12
+ _PREFIX = 'bin/'
13
+
14
+
15
+ @app.command()
16
+ @bfunc.syncCall
17
+ async def init(
18
+ ak: str = typer.Argument(..., help="七牛云账号AK"),
19
+ sk: str = typer.Argument(..., help="七牛云账号SK"),
20
+ ):
21
+ '初始化七牛云服务'
22
+ await bstore.set(__file__, (ak, sk))
23
+ bcolor.printGreen('OK')
24
+
25
+
26
+ @app.command()
27
+ @bfunc.syncCall
28
+ async def clear():
29
+ '清空 token'
30
+ await bstore.clear(__file__)
31
+ bcolor.printGreen('OK')
32
+
33
+
34
+ @app.command()
35
+ @bfunc.syncCall
36
+ async def download(
37
+ names: str = typer.Argument(None, help="如果有多个使用,分割"),
38
+ file: Path = typer.Option(None, '--file', '-f', help="文件形式指定参数,行为单位"),
39
+ output: Path = typer.Option(None, '--output', '-o', help="本地保存路径"),
40
+ ):
41
+ '从七牛云下载执行文件'
42
+ bucket = await _getBucket()
43
+ if bucket:
44
+ if output is None:
45
+ output = Path(os.curdir)
46
+ output = output.resolve()
47
+ targetList: list[str] = []
48
+ if names:
49
+ targetList.extend(names.split(','))
50
+ if file:
51
+ content = await bfile.readText(Path(file))
52
+ targetList.extend(content.split('\n'))
53
+ targetList = [x.strip() for x in targetList]
54
+ targetList = [x for x in targetList if x]
55
+ for target in targetList:
56
+ binFile = output / target
57
+ if binFile.exists():
58
+ bcolor.printYellow(f'已存在 {binFile}')
59
+ else:
60
+ key = f'bin/{target}.zip'
61
+ await bucket.downloadPrivateFileUnzip(key, output)
62
+ bcolor.printGreen(f'added {binFile}')
63
+
64
+
65
+ @app.command('list')
66
+ @bfunc.syncCall
67
+ async def getList():
68
+ '列出可下载的文件'
69
+ bucket = await _getBucket()
70
+ if bucket:
71
+ datas = (await bucket.getFileList(_PREFIX, limit=1000))[0]
72
+ datas = [x for x in datas if x.key != _PREFIX and x.key.endswith('.zip')]
73
+ print(
74
+ btable.get(
75
+ datas,
76
+ fields=[
77
+ ('名称<', lambda x: x.key[len(_PREFIX):-len('.zip')]),
78
+ ('时间<', lambda x: datetime.fromtimestamp(x.time / 10000000).strftime('%Y-%m-%d %H:%M:%S')),
79
+ ]
80
+ )
81
+ )
82
+
83
+
84
+ async def _getBucket():
85
+ try:
86
+ (ak, sk) = await bstore.get(__file__)
87
+ return QiniuBucket(
88
+ 'pytask',
89
+ 'http://qiniu-cdn.pytask.com',
90
+ ak,
91
+ sk,
92
+ )
93
+ except:
94
+ bcolor.printRed('请先执行 beni bin init 进行初始化')
@@ -11,13 +11,13 @@ app: Final = btask.newSubApp('lib 工具')
11
11
  @app.command()
12
12
  @bfunc.syncCall
13
13
  async def version(
14
- workspacePath: Path = typer.Argument(None, help='workspace 路径'),
15
- disabledCommit: bool = typer.Option(False, '--disabled-commit', '-d', help='是否提交git'),
14
+ workspace_path: Path = typer.Argument(None, help='workspace 路径'),
15
+ disabled_commit: bool = typer.Option(False, '--disabled-commit', '-d', help='是否提交git'),
16
16
  ):
17
17
  '修改 pyproject.toml 版本号'
18
- if workspacePath is None:
19
- workspacePath = Path.cwd()
20
- file = workspacePath / 'pyproject.toml'
18
+ if workspace_path is None:
19
+ workspace_path = Path.cwd()
20
+ file = workspace_path / 'pyproject.toml'
21
21
  assert file.is_file(), f'文件不存在 {file}'
22
22
  data = await bfile.readToml(file)
23
23
  version = data['project']['version']
@@ -32,7 +32,7 @@ async def version(
32
32
  else:
33
33
  raise Exception('版本号修改失败,先检查文件中定义的版本号格式是否正常')
34
34
  await bfile.writeText(file, content)
35
- if not disabledCommit:
35
+ if not disabled_commit:
36
36
  os.system(
37
37
  rf'TortoiseGitProc.exe /command:commit /path:{file} /logmsg:"更新版本号 {newVersion}"'
38
38
  )
@@ -81,15 +81,19 @@ async def tidy(
81
81
  tasks_path: Path = typer.Argument(None, help="tasks 路径"),
82
82
  ):
83
83
  '整理 tasks 文件'
84
+ initFile = tasks_path / '__init__.py'
85
+ assert initFile.is_file(), f'文件不存在 {initFile}'
84
86
  files = await bpath.listFile(tasks_path)
85
87
  files = [x for x in files if not x.name.startswith('_')]
86
88
  contents = [f'from . import {x.stem}' for x in files]
87
89
  contents.insert(0, '# type: ignore')
88
90
  contents.append('')
91
+ content = '\n'.join(contents)
89
92
  await bfile.writeText(
90
- tasks_path / '__init__.py',
91
- '\n'.join(contents),
93
+ initFile,
94
+ content,
92
95
  )
96
+ print(content)
93
97
 
94
98
 
95
99
  _files = '''
@@ -203,70 +207,61 @@ venv/
203
207
  ],
204
208
  },
205
209
  {
206
- "label": "update version",
210
+ "label": "tasks tidy",
207
211
  "type": "shell",
208
212
  "problemMatcher": [],
209
213
  "command": "beni",
210
214
  "args": [
211
- "lib",
212
- "version",
213
- "${workspaceFolder}"
215
+ "task",
216
+ "tidy",
217
+ "${workspaceFolder}/tasks"
214
218
  ],
215
219
  },
216
220
  ],
217
221
  }
218
222
 
219
223
 
220
- >>> src/dev.py
221
- import main
222
- from beni import btask
223
-
224
- main.init()
225
-
226
- btask.dev('sub.haha')
227
-
228
-
229
224
  >>> src/main.py
230
- from beni import btask, bpath
231
-
232
-
233
- def init():
234
- btask.options.tasksPath = bpath.get(__file__, '../tasks')
235
- btask.options.lock = 'xxxxxx'
225
+ import asyncio
236
226
 
227
+ from beni import btask
237
228
 
238
- def run():
239
- init()
240
- btask.main()
229
+ from tasks import *
241
230
 
231
+ btask.options.lock = 'bcmd'
232
+ asyncio.run(btask.main())
242
233
 
243
- if __name__ == '__main__':
244
- run()
245
234
 
246
235
 
247
236
  >>> src/tasks/__init__.py
237
+ # type: ignore
238
+ from . import hello
239
+ from . import sub
248
240
 
249
241
 
250
242
 
251
243
  >>> src/tasks/hello.py
244
+ from typing import Final
245
+
252
246
  from beni import bfunc, btask
253
247
 
248
+ app: Final = btask.app
249
+
254
250
 
255
- @btask.app.command()
251
+ @app.command()
256
252
  @bfunc.syncCall
257
253
  async def hello():
258
254
  '打印 hello'
259
255
  print('hello')
260
256
 
261
257
 
258
+
262
259
  >>> src/tasks/sub.py
263
260
  from typing import Final
264
261
 
265
- import typer
266
- from beni import bfunc
267
-
262
+ from beni import bfunc, btask
268
263
 
269
- app: Final = typer.Typer(help='子工具集')
264
+ app: Final = btask.newSubApp('子工具集')
270
265
 
271
266
 
272
267
  @app.command()
@@ -283,13 +278,14 @@ async def bye():
283
278
  print('bye')
284
279
 
285
280
 
281
+
286
282
  >>> venv.list
287
283
  aioconsole
288
284
  aiofiles
289
285
  aiohttp
290
286
  aiosqlite
291
287
  autopep8
292
- benimang==0.4.10
288
+ benimang==0.4.13
293
289
  nest-asyncio
294
290
  orjson
295
291
  portalocker
@@ -300,4 +296,4 @@ pyinstaller
300
296
  pyyaml
301
297
  qiniu
302
298
  typer
303
- '''
299
+ '''
@@ -1,9 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bcmd
3
- Version: 0.0.26
3
+ Version: 0.0.27
4
4
  Summary: Commands for Beni
5
- Author: Beni Mang
6
- Author-email: benimang@126.com
5
+ Author-email: Beni Mang <benimang@126.com>
7
6
  Maintainer-email: Beni Mang <benimang@126.com>
8
7
  Keywords: benimang,beni,bcmd
9
8
  Requires-Python: >=3.10
@@ -2,7 +2,7 @@ aioconsole
2
2
  aiofiles
3
3
  aiohttp
4
4
  autopep8
5
- benimang>=0.4.13
5
+ benimang<0.5
6
6
  build
7
7
  colorama
8
8
  nest-asyncio
@@ -3,24 +3,19 @@
3
3
 
4
4
  [project]
5
5
  name = 'bcmd'
6
- version = '0.0.26'
6
+ version = '0.0.27'
7
7
  description = 'Commands for Beni'
8
8
  requires-python = '>=3.10'
9
9
  keywords = ['benimang', 'beni', 'bcmd']
10
- authors = [
11
- {email = 'benimang@126.com'},
12
- {name = 'Beni Mang'},
13
- ]
14
- maintainers = [
15
- {name = 'Beni Mang', email = 'benimang@126.com'},
16
- ]
10
+ authors = [{ name = 'Beni Mang', email = 'benimang@126.com' }]
11
+ maintainers = [{ name = 'Beni Mang', email = 'benimang@126.com' }]
17
12
 
18
13
  dependencies = [
19
14
  'aioconsole',
20
15
  'aiofiles',
21
16
  'aiohttp',
22
17
  'autopep8',
23
- 'benimang>=0.4.13',
18
+ 'benimang<0.5',
24
19
  'build',
25
20
  'colorama',
26
21
  'nest-asyncio',
@@ -35,4 +30,4 @@ dependencies = [
35
30
  ]
36
31
 
37
32
  [project.scripts]
38
- beni = 'bcmd.main:run'
33
+ beni = 'bcmd.main:run'
@@ -1,56 +0,0 @@
1
- import os
2
- from pathlib import Path
3
- from typing import Final
4
-
5
- import typer
6
- from beni import bcolor, bfile, bfunc, bstore, btask
7
- from beni.bqiniu import QiniuBucket
8
-
9
-
10
- app: Final = btask.newSubApp('bin 工具')
11
-
12
-
13
- @app.command()
14
- @bfunc.syncCall
15
- async def init(
16
- ak: str = typer.Argument(..., help="七牛云账号AK"),
17
- sk: str = typer.Argument(..., help="七牛云账号SK"),
18
- ):
19
- '初始化七牛云服务'
20
- await bstore.set(__file__, (ak, sk))
21
-
22
-
23
- @app.command()
24
- @bfunc.syncCall
25
- async def download(
26
- names: str = typer.Argument(None, help="如果有多个使用,分割"),
27
- file: Path = typer.Option(None, '--file', '-f', help="文件形式指定参数,行为单位"),
28
- output: Path = typer.Option(None, '--output', '-o', help="本地保存路径"),
29
- ):
30
- '从七牛云下载执行文件'
31
- try:
32
- (ak, sk) = await bstore.get(__file__)
33
- except:
34
- return bcolor.printRed('请先执行 beni bin init 进行初始化')
35
- bucketName = 'pytask'
36
- bucketUrl = 'http://qiniu-cdn.pytask.com'
37
- if output is None:
38
- output = Path(os.curdir)
39
- output = output.resolve()
40
- bucket = QiniuBucket(bucketName, bucketUrl, ak, sk)
41
- targetList: list[str] = []
42
- if names:
43
- targetList.extend(names.split(','))
44
- if file:
45
- content = await bfile.readText(Path(file))
46
- targetList.extend(content.split('\n'))
47
- targetList = [x.strip() for x in targetList]
48
- targetList = [x for x in targetList if x]
49
- for target in targetList:
50
- binFile = output / target
51
- if binFile.exists():
52
- bcolor.printYellow(f'已存在 {binFile}')
53
- else:
54
- key = f'bin/{target}.zip'
55
- await bucket.downloadPrivateFileUnzip(key, output)
56
- bcolor.printGreen(f'added {binFile}')
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