bcmd 0.5.8__tar.gz → 0.5.11__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.

Files changed (39) hide show
  1. {bcmd-0.5.8 → bcmd-0.5.11}/PKG-INFO +3 -2
  2. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/__init__.py +2 -0
  3. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/crypto.py +4 -15
  4. bcmd-0.5.11/bcmd/tasks/pdf.py +43 -0
  5. bcmd-0.5.11/bcmd/tasks/wasabi.py +66 -0
  6. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd.egg-info/PKG-INFO +3 -2
  7. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd.egg-info/SOURCES.txt +3 -1
  8. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd.egg-info/requires.txt +2 -1
  9. {bcmd-0.5.8 → bcmd-0.5.11}/pyproject.toml +4 -2
  10. {bcmd-0.5.8 → bcmd-0.5.11}/MANIFEST.in +0 -0
  11. {bcmd-0.5.8 → bcmd-0.5.11}/README.md +0 -0
  12. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/__init__.py +0 -0
  13. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/common/__init__.py +0 -0
  14. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/common/func.py +0 -0
  15. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/common/password.py +0 -0
  16. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/main.py +0 -0
  17. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/resources/project/.gitignore +0 -0
  18. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/resources/project/.vscode/launch.json +0 -0
  19. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/resources/project/.vscode/settings.json +0 -0
  20. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/resources/project/.vscode/tasks.json +0 -0
  21. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/resources/project/main.py +0 -0
  22. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/bin.py +0 -0
  23. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/code.py +0 -0
  24. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/debian.py +0 -0
  25. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/download.py +0 -0
  26. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/image.py +0 -0
  27. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/json.py +0 -0
  28. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/lib.py +0 -0
  29. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/math.py +0 -0
  30. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/mirror.py +0 -0
  31. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/project.py +0 -0
  32. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/proxy.py +0 -0
  33. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/time.py +0 -0
  34. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/upgrade.py +0 -0
  35. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd/tasks/venv.py +0 -0
  36. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd.egg-info/dependency_links.txt +0 -0
  37. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd.egg-info/entry_points.txt +0 -0
  38. {bcmd-0.5.8 → bcmd-0.5.11}/bcmd.egg-info/top_level.txt +0 -0
  39. {bcmd-0.5.8 → bcmd-0.5.11}/setup.cfg +0 -0
@@ -1,18 +1,19 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: bcmd
3
- Version: 0.5.8
3
+ Version: 0.5.11
4
4
  Summary: Commands for Beni
5
5
  Author-email: Beni Mang <benimang@126.com>
6
6
  Maintainer-email: Beni Mang <benimang@126.com>
7
7
  Keywords: benimang,beni,bcmd
8
8
  Requires-Python: >=3.10
9
- Requires-Dist: benimang==0.7.12
9
+ Requires-Dist: benimang==0.7.13
10
10
  Requires-Dist: build
11
11
  Requires-Dist: cryptography
12
12
  Requires-Dist: pathspec
13
13
  Requires-Dist: pillow
14
14
  Requires-Dist: prettytable
15
15
  Requires-Dist: psutil
16
+ Requires-Dist: pymupdf
16
17
  Requires-Dist: qiniu
17
18
  Requires-Dist: twine
18
19
  Requires-Dist: typer
@@ -9,8 +9,10 @@ from . import json
9
9
  from . import lib
10
10
  from . import math
11
11
  from . import mirror
12
+ from . import pdf
12
13
  from . import project
13
14
  from . import proxy
14
15
  from . import time
15
16
  from . import upgrade
16
17
  from . import venv
18
+ from . import wasabi
@@ -7,6 +7,7 @@ import pyperclip
7
7
  import typer
8
8
  from beni import bcolor, bcrypto, btask
9
9
  from beni.bfunc import syncCall
10
+ from beni.binput import genPassword
10
11
  from rich.console import Console
11
12
 
12
13
  app: Final = btask.newSubApp('加密(v2)')
@@ -19,7 +20,7 @@ async def encrypt_text():
19
20
  content = pyperclip.paste()
20
21
  assert content, '剪贴板内容不能为空'
21
22
  bcolor.printGreen(content)
22
- password = _genPassword()
23
+ password = genPassword()
23
24
  result = bcrypto.encryptText(content, password)
24
25
  pyperclip.copy(result)
25
26
  print('密文已复制到剪贴板')
@@ -55,7 +56,7 @@ async def encrypt_json():
55
56
  except:
56
57
  return btask.abort('错误:剪贴板内容必须是JSON格式', content)
57
58
  Console().print_json(data=data, indent=4, ensure_ascii=False, sort_keys=True)
58
- password = _genPassword()
59
+ password = genPassword()
59
60
  result = bcrypto.encryptJson(data, password)
60
61
  pyperclip.copy(result)
61
62
  print('密文已复制到剪贴板')
@@ -87,7 +88,7 @@ async def encrypt_file(
87
88
  ):
88
89
  '加密文件(文件路径使用剪贴板内容)'
89
90
  assert file.is_file(), '文件不存在'
90
- password = _genPassword()
91
+ password = genPassword()
91
92
  await bcrypto.encryptFile(file, password)
92
93
  bcolor.printGreen('OK')
93
94
 
@@ -102,15 +103,3 @@ async def decrypt_file(
102
103
  password = getpass.getpass('输入密码:')
103
104
  await bcrypto.decryptFile(file, password)
104
105
  bcolor.printGreen('OK')
105
-
106
-
107
- # ------------------------------------------------------------------------------------
108
-
109
-
110
- def _genPassword():
111
- password = ''
112
- while not password:
113
- password = getpass.getpass('输入密码:')
114
- while password != getpass.getpass('再次密码:'):
115
- pass
116
- return password
@@ -0,0 +1,43 @@
1
+ from pathlib import Path
2
+ from typing import Final
3
+
4
+ import fitz
5
+ import typer
6
+ from beni import bcolor, bfile, btask
7
+ from beni.bfunc import syncCall
8
+
9
+ app: Final = btask.newSubApp('PDF相关')
10
+
11
+
12
+ @app.command()
13
+ @syncCall
14
+ async def output_images(
15
+ target: Path = typer.Option(Path.cwd(), '--target', help='PDF文件路径或多个PDF文件所在的目录'),
16
+ ):
17
+ '保存 PDF 文件里面的图片'
18
+
19
+ # 列出需要检查的PDF文件
20
+ pdfFileList: list[Path] = []
21
+ if target.is_dir():
22
+ pdfFileList = list(target.glob('*.pdf'))
23
+ elif target.is_file():
24
+ pdfFileList = [target]
25
+ else:
26
+ raise ValueError("目标路径不存在")
27
+
28
+ for pdf_file in pdfFileList:
29
+ pdf_document = fitz.open(pdf_file)
30
+ output_dir = pdf_file.with_name(pdf_file.stem + '-PDF图片文件')
31
+ for page_num in range(len(pdf_document)):
32
+ page = pdf_document.load_page(page_num)
33
+ images = page.get_images(full=True)
34
+ for img_index, img in enumerate(images):
35
+ xref = img[0]
36
+ base_image = pdf_document.extract_image(xref)
37
+ image_bytes = base_image["image"]
38
+ image_ext = base_image["ext"]
39
+ image_filename = f"page{page_num + 1}_img{img_index + 1}.{image_ext}"
40
+ image_path = output_dir / image_filename
41
+ output_dir.mkdir(exist_ok=True)
42
+ bcolor.printGreen(image_path)
43
+ await bfile.writeBytes(image_path, image_bytes)
@@ -0,0 +1,66 @@
1
+ import getpass
2
+ from pathlib import Path
3
+ from typing import Final
4
+
5
+ import typer
6
+ from beni import bcolor, bcrypto, bfile, bpath, btask, bzip
7
+ from beni.bfunc import shuffleSequence, syncCall
8
+ from beni.binput import genPassword
9
+
10
+ app: Final = btask.newSubApp('Wasabi 工具')
11
+
12
+ SEP = f'{chr(852)}{chr(322)}{chr(470)}'.encode()
13
+ MAX_ENCRYPT_SIZE = 199 * 1024
14
+
15
+
16
+ @app.command()
17
+ @syncCall
18
+ async def to_dir(
19
+ file: Path = typer.Argument(Path.cwd(), help='工作文件'),
20
+ password: str = typer.Option('', '--password', '-p', help='密码'),
21
+ ):
22
+ '生成目录'
23
+ assert file.is_file(), f'不是文件 {file}'
24
+ workspace = file.parent / file.stem
25
+ assert not workspace.exists(), f'目录已存在 {workspace}'
26
+ password = password or getpass.getpass('请输入密码: ')
27
+ with bpath.useTempFile() as tempFile:
28
+ data = await bfile.readBytes(file)
29
+ if SEP not in data:
30
+ data = bcrypto.decrypt(data, password)
31
+ else:
32
+ partA, partB = data.split(SEP)
33
+ partA = bcrypto.decrypt(partA, password)
34
+ data = partA + partB
35
+ data = shuffleSequence(data)
36
+ await bfile.writeBytes(tempFile, data)
37
+ await bzip.sevenUnzip(tempFile, workspace)
38
+ bcolor.printGreen(workspace)
39
+ bcolor.printGreen('OK')
40
+
41
+
42
+ @app.command()
43
+ @syncCall
44
+ async def to_file(
45
+ workspace: Path = typer.Argument(Path.cwd(), help='工作目录'),
46
+ password: str = typer.Option('', '--password', '-p', help='密码'),
47
+ ):
48
+ '生成文件'
49
+ assert workspace.is_dir(), f'不是目录 {workspace}'
50
+ zipFile = workspace.parent / f'{workspace.name}.dat'
51
+ assert not zipFile.exists(), f'文件已存在 {zipFile}'
52
+ password = password or genPassword()
53
+ with bpath.useTempFile() as tempFile:
54
+ await bzip.sevenZipFolder(tempFile, workspace)
55
+ data = await bfile.readBytes(tempFile)
56
+ bpath.remove(tempFile)
57
+ data = shuffleSequence(data)
58
+ if len(data) < MAX_ENCRYPT_SIZE:
59
+ data = bcrypto.encrypt(data, password)
60
+ else:
61
+ partA, partB = data[:MAX_ENCRYPT_SIZE], data[MAX_ENCRYPT_SIZE:]
62
+ partA = bcrypto.encrypt(partA, password)
63
+ data = partA + SEP + partB
64
+ await bfile.writeBytes(zipFile, data)
65
+ bcolor.printGreen(zipFile)
66
+ bcolor.printGreen('OK')
@@ -1,18 +1,19 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: bcmd
3
- Version: 0.5.8
3
+ Version: 0.5.11
4
4
  Summary: Commands for Beni
5
5
  Author-email: Beni Mang <benimang@126.com>
6
6
  Maintainer-email: Beni Mang <benimang@126.com>
7
7
  Keywords: benimang,beni,bcmd
8
8
  Requires-Python: >=3.10
9
- Requires-Dist: benimang==0.7.12
9
+ Requires-Dist: benimang==0.7.13
10
10
  Requires-Dist: build
11
11
  Requires-Dist: cryptography
12
12
  Requires-Dist: pathspec
13
13
  Requires-Dist: pillow
14
14
  Requires-Dist: prettytable
15
15
  Requires-Dist: psutil
16
+ Requires-Dist: pymupdf
16
17
  Requires-Dist: qiniu
17
18
  Requires-Dist: twine
18
19
  Requires-Dist: typer
@@ -28,8 +28,10 @@ bcmd/tasks/json.py
28
28
  bcmd/tasks/lib.py
29
29
  bcmd/tasks/math.py
30
30
  bcmd/tasks/mirror.py
31
+ bcmd/tasks/pdf.py
31
32
  bcmd/tasks/project.py
32
33
  bcmd/tasks/proxy.py
33
34
  bcmd/tasks/time.py
34
35
  bcmd/tasks/upgrade.py
35
- bcmd/tasks/venv.py
36
+ bcmd/tasks/venv.py
37
+ bcmd/tasks/wasabi.py
@@ -1,10 +1,11 @@
1
- benimang==0.7.12
1
+ benimang==0.7.13
2
2
  build
3
3
  cryptography
4
4
  pathspec
5
5
  pillow
6
6
  prettytable
7
7
  psutil
8
+ pymupdf
8
9
  qiniu
9
10
  twine
10
11
  typer
@@ -3,7 +3,7 @@
3
3
 
4
4
  [project]
5
5
  name = 'bcmd'
6
- version = '0.5.8'
6
+ version = '0.5.11'
7
7
  description = 'Commands for Beni'
8
8
  requires-python = '>=3.10'
9
9
  keywords = ['benimang', 'beni', 'bcmd']
@@ -12,16 +12,18 @@ maintainers = [{ name = 'Beni Mang', email = 'benimang@126.com' }]
12
12
 
13
13
 
14
14
  dependencies = [
15
- 'benimang==0.7.12',
15
+ 'benimang==0.7.13',
16
16
  'build',
17
17
  'cryptography',
18
18
  'pathspec',
19
19
  'pillow',
20
20
  'prettytable',
21
21
  'psutil',
22
+ 'pymupdf',
22
23
  'qiniu',
23
24
  'twine',
24
25
  'typer',
26
+ # 'img2pdf',
25
27
  # 'pytest',
26
28
  # 'pytest-asyncio',
27
29
  # 'pytest-order',
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
File without changes
File without changes
File without changes
File without changes
File without changes