bcmd 0.6.4__py3-none-any.whl → 0.6.5__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bcmd
3
- Version: 0.6.4
3
+ Version: 0.6.5
4
4
  Summary: Commands for Beni
5
5
  Author-email: Beni Mang <benimang@126.com>
6
6
  Maintainer-email: Beni Mang <benimang@126.com>
@@ -12,7 +12,7 @@ bcmdx/tasks/debian.py,sha256=B9aMIIct3vNqMJr5hTr1GegXVf20H49C27FMvRRGIzI,3004
12
12
  bcmdx/tasks/download.py,sha256=XdZYKi8zQTNYWEgUxeTNDqPgP7IGYJkMmlDDC9u93Vk,2315
13
13
  bcmdx/tasks/image.py,sha256=Q8ujT6tq2tt0qS0DIY87PNG2RJ1wSArt2dHVTtCuccA,12161
14
14
  bcmdx/tasks/json.py,sha256=WWOyvcZPYaqQgp-Tkm-uIJschNMBKPKtZN3yXz_SC5s,635
15
- bcmdx/tasks/lib.py,sha256=Ofx2rSeqBZtVaRM4ly6ORyAozMgk5b8TTM9cy8vCa_E,1904
15
+ bcmdx/tasks/lib.py,sha256=4Ge0DQe4J7hyg2S-kJQ22MDbvO-E7BoyM00etNsxowc,2751
16
16
  bcmdx/tasks/math.py,sha256=xbl5UdaDMyAjiLodDPleP4Cutrk2S3NOAgurzAgOEAE,2862
17
17
  bcmdx/tasks/mirror.py,sha256=nAe8NYftMKzht16MFBj7RqXwvVhR6Jh2uuAyJLh87og,1098
18
18
  bcmdx/tasks/pdf.py,sha256=fkHRgxqzrRxdb4_-9pL9wp2roqAHJPS_dVqAGJvRUsM,1504
@@ -20,8 +20,10 @@ bcmdx/tasks/proxy.py,sha256=xvxN5PClUnc5LQpmq2Wug7_LUVpJboMWLXBvL9lX7EM,1552
20
20
  bcmdx/tasks/time.py,sha256=ZiqA1jdgl-TBtFSOxxP51nwv4g9iZItmkFKpf9MKelk,2453
21
21
  bcmdx/tasks/upgrade.py,sha256=z9Ein8U_Co7fsijPxyDFM8tXBFCp4bWATImwwwvC5ho,536
22
22
  bcmdx/tasks/wasabi.py,sha256=xWFAxprSIlBqDDMGaNXZFb-SahnW1d_R9XxSKRYIhnM,3110
23
- bcmd-0.6.4.dist-info/METADATA,sha256=Kaukt2ZCQj7HwwmiugzGW2pn34QG84aA1CGezh7Qqx8,812
24
- bcmd-0.6.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- bcmd-0.6.4.dist-info/entry_points.txt,sha256=p7bvtyio57ADkhcYAQeVus3iwXlSlcUwmuLtyR2qslQ,40
26
- bcmd-0.6.4.dist-info/top_level.txt,sha256=rFHAQCIe-D-4iY7llhCS6cRDYfRIhHh9knGydcCiQjQ,6
27
- bcmd-0.6.4.dist-info/RECORD,,
23
+ bcmdx/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ bcmdx/utils/tkUtil.py,sha256=Juj0be7i3wCBIZBFic4ye76ZfsVLkFiw50J266e5-0U,4685
25
+ bcmd-0.6.5.dist-info/METADATA,sha256=O89LvsZh4ht3n6a15QOaAqzN6_eJd5PKZ1QnS3FOjNU,812
26
+ bcmd-0.6.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ bcmd-0.6.5.dist-info/entry_points.txt,sha256=p7bvtyio57ADkhcYAQeVus3iwXlSlcUwmuLtyR2qslQ,40
28
+ bcmd-0.6.5.dist-info/top_level.txt,sha256=rFHAQCIe-D-4iY7llhCS6cRDYfRIhHh9knGydcCiQjQ,6
29
+ bcmd-0.6.5.dist-info/RECORD,,
bcmdx/tasks/lib.py CHANGED
@@ -6,6 +6,8 @@ import typer
6
6
  from beni import bcolor, bfile, bpath, brun, btask
7
7
  from beni.bfunc import syncCall
8
8
 
9
+ from bcmdx.utils.tkUtil import TkForm
10
+
9
11
  from ..common import password
10
12
 
11
13
  app: Final = btask.newSubApp('lib 工具')
@@ -21,23 +23,55 @@ async def update_version(
21
23
  file = path / 'pyproject.toml'
22
24
  btask.assertTrue(file.is_file(), '文件不存在', file)
23
25
  data = await bfile.readToml(file)
24
- version = data['project']['version']
25
- versionList = [int(x) for x in version.split('.')]
26
- versionList[-1] += 1
27
- newVersion = '.'.join([str(x) for x in versionList])
26
+ latestVersion = data['project']['version']
27
+ vAry = [int(x) for x in latestVersion.split('.')]
28
+ versionList = [
29
+ f'{vAry[0] + 1}.0.0',
30
+ f'{vAry[0]}.{vAry[1] + 1}.0',
31
+ f'{vAry[0]}.{vAry[1]}.{vAry[2] + 1}',
32
+ ]
33
+
34
+ def showGui():
35
+ app = TkForm()
36
+ app.title('bcmd 版本更新')
37
+ app.addLabel('当前版本号', latestVersion)
38
+ version_var = app.addRadioBtn(
39
+ '请选择新版本',
40
+ versionList,
41
+ selectedIndex=-1,
42
+ )
43
+ result: str = ''
44
+
45
+ def onBtn():
46
+ nonlocal result
47
+ result = version_var.get()
48
+ app.destroy()
49
+
50
+ app.addBtn('确定', onBtn, focus=True)
51
+ app.run()
52
+ return result
53
+
54
+ newVersion = showGui()
55
+ if not newVersion:
56
+ btask.abort('用户取消操作')
28
57
  content = await bfile.readText(file)
29
- if f"version = '{version}'" in content:
30
- content = content.replace(f"version = '{version}'", f"version = '{newVersion}'")
31
- elif f'version = "{version}"' in content:
32
- content = content.replace(f'version = "{version}"', f'version = "{newVersion}"')
58
+ if f"version = '{latestVersion}'" in content:
59
+ content = content.replace(f"version = '{latestVersion}'", f"version = '{newVersion}'")
60
+ elif f'version = "{latestVersion}"' in content:
61
+ content = content.replace(f'version = "{latestVersion}"', f'version = "{newVersion}"')
33
62
  else:
34
63
  raise Exception('版本号修改失败,先检查文件中定义的版本号格式是否正常')
35
64
  await bfile.writeText(file, content)
65
+
66
+ # 执行一遍 uv.lock
67
+ with bpath.changePath(path):
68
+ await brun.run('uv lock')
69
+
36
70
  bcolor.printCyan(newVersion)
37
71
  if not isNotCommit:
38
72
  msg = f'更新版本号 {newVersion}'
39
73
  os.system(
40
- rf'TortoiseGitProc.exe /command:commit /path:{file} /logmsg:"{msg}"'
74
+ rf'TortoiseGitProc.exe /command:commit /path:{path} /logmsg:"{msg}"'
41
75
  )
42
76
  bcolor.printGreen('OK')
43
77
 
@@ -56,3 +90,4 @@ async def build(
56
90
  with bpath.changePath(path):
57
91
  await brun.run(f'uv build')
58
92
  await brun.run(f'uv publish -u {user} -p {pwd}')
93
+ bcolor.printGreen('OK')
File without changes
bcmdx/utils/tkUtil.py ADDED
@@ -0,0 +1,130 @@
1
+ import tkinter as tk
2
+ from tkinter.scrolledtext import ScrolledText
3
+ from typing import Callable
4
+ from uuid import uuid4
5
+
6
+ # version 2026-0621
7
+
8
+
9
+ class TkForm(tk.Tk):
10
+
11
+ _row = -1
12
+ _initFocusItem: tk.Widget | None = None
13
+
14
+ RADIO_NOTHING = uuid4().hex
15
+
16
+ def __init__(self):
17
+ super().__init__()
18
+ self.resizable(False, False)
19
+ self.bind("<Map>", self._onMap)
20
+
21
+ def _onMap(self, event: tk.Event):
22
+ if self._initFocusItem:
23
+ self._initFocusItem.focus_set()
24
+ self._initFocusItem = None
25
+
26
+ def add(self, desc: str, widget: tk.Widget):
27
+ self._row += 1
28
+ tk.Label(text=desc).grid(row=self._row, column=0, padx=10, pady=5, sticky='n')
29
+ widget.grid(row=self._row, column=1, padx=10, pady=5, sticky='w')
30
+
31
+ def addFrame(self, frame: tk.Frame):
32
+ self._row += 1
33
+ frame.grid(row=self._row, column=0, columnspan=2, padx=10, pady=5)
34
+
35
+ def run(self):
36
+ self.center()
37
+ self.mainloop()
38
+
39
+ def center(self):
40
+ self.withdraw() # 先隐藏窗口,避免闪动
41
+ self.update_idletasks() # 确保获取正确的窗口尺寸
42
+ width = self.winfo_width() # 获取窗口宽度
43
+ height = self.winfo_height() # 获取窗口高度
44
+ screen_width = self.winfo_screenwidth() # 屏幕宽度
45
+ screen_height = self.winfo_screenheight() # 屏幕高度
46
+ x = (screen_width - width) // 2 # 水平居中
47
+ y = (screen_height - height) // 2 # 垂直居中
48
+ self.geometry(f"+{x}+{y}") # 设置窗口位置
49
+ self.deiconify() # 恢复显示窗口
50
+
51
+ def addLabel(self, desc: str, text: str):
52
+ self.add(desc, tk.Label(text=text))
53
+
54
+ def addBtn(self, label: str, command: Callable[..., None], *, width: int = 20, focus: bool = False):
55
+ frame = tk.Frame(self)
56
+ self.addFrame(frame)
57
+ btn = tk.Button(frame, text=label, width=width, command=command)
58
+ btn.pack(side="left", expand=True, padx=15)
59
+ if focus:
60
+ self._initFocusItem = btn
61
+
62
+ def addRadioBtn(self, desc: str, selectionList: list[str], *, selectedIndex: int | None = None, focusIndex: int | None = None):
63
+ frame = tk.Frame()
64
+ self.add(desc, frame)
65
+ var = tk.StringVar(value=selectionList[selectedIndex] if selectedIndex is not None else self.RADIO_NOTHING)
66
+ radioBtnList: list[tk.Radiobutton] = []
67
+ for version in selectionList:
68
+ radioBtn = tk.Radiobutton(frame, text=version, variable=var, value=version)
69
+ radioBtn.pack(side="left", padx=(0, 15))
70
+ radioBtnList.append(radioBtn)
71
+ if focusIndex is not None:
72
+ self._initFocusItem = radioBtnList[focusIndex]
73
+ return var
74
+
75
+ def addEntry(self, desc: str, text: str = '', *, width: int = 60, focus: bool = False):
76
+ entry = tk.Entry(self, width=30)
77
+ entry.insert(0, text)
78
+ self.add(desc, entry)
79
+ if focus:
80
+ self._initFocusItem = entry
81
+ return entry
82
+
83
+ def addScrolledText(self, desc: str, text: str = '', *, width: int = 60, height: int = 20, focus: bool = False):
84
+ scrolledText = ScrolledText(self, width=width, height=height)
85
+ scrolledText.insert("1.0", text)
86
+ self.add(desc, scrolledText)
87
+ if focus:
88
+ self._initFocusItem = scrolledText
89
+ return scrolledText
90
+
91
+ def addCheckBox(self, text: str, value: bool = False):
92
+ remember_var = tk.BooleanVar(value=value)
93
+ check_btn = tk.Checkbutton(text=text, variable=remember_var)
94
+ self.add("", check_btn)
95
+ return remember_var
96
+
97
+ def addPasswordInput(self, desc: str, *, width: int = 60, command: Callable[..., None] | None = None):
98
+ password_entry = tk.Entry(self, show="*", width=width) # 使用 show="*" 隐藏输入内容
99
+ if command:
100
+ password_entry.bind('<Return>', lambda event: command())
101
+ self.add(desc, password_entry)
102
+ return password_entry
103
+
104
+
105
+ ''' 例子
106
+ app = TkForm()
107
+ app.title('更新版本信息')
108
+ app.addLabel('当前版本号', '3.11.8')
109
+ app.addLabel('上次更新时间', '2025-06-16 16:00:00')
110
+ version_var = app.addRadioBtn(
111
+ '请选择新版本',
112
+ ['3.11.8', '3.11.9', '3.11.10'],
113
+ 2,
114
+ )
115
+ log_text = app.addScrolledText('更新日志', '123\n23454asd这个')
116
+ vara = app.addCheckBox('记住密码', False)
117
+ varb = app.addCheckBox('阿萨德法师大润发', True)
118
+ passwordInput = app.addPasswordInput('密码', command=lambda: onBtn())
119
+
120
+
121
+ def onBtn():
122
+ print(version_var.get())
123
+ print(log_text.get('1.0', "end-1c").split('\n'))
124
+ app.destroy()
125
+
126
+
127
+ app.addBtn('确定', onBtn)
128
+ app.bind("<Visibility>", lambda e: passwordInput.focus_set())
129
+ app.run()
130
+ '''
File without changes