bcmd 0.5.3__tar.gz → 0.5.5__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.5.3 → bcmd-0.5.5}/PKG-INFO +1 -1
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/resources/project/.gitignore +3 -3
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/resources/project/.vscode/settings.json +10 -10
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/code.py +45 -14
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/image.py +7 -3
- bcmd-0.5.5/bcmd/tasks/project.py +59 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/proxy.py +1 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/venv.py +17 -8
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd.egg-info/PKG-INFO +1 -1
- {bcmd-0.5.3 → bcmd-0.5.5}/pyproject.toml +1 -1
- bcmd-0.5.3/bcmd/tasks/project.py +0 -34
- {bcmd-0.5.3 → bcmd-0.5.5}/MANIFEST.in +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/README.md +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/__init__.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/common/__init__.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/common/func.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/common/password.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/main.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/resources/project/.vscode/launch.json +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/resources/project/.vscode/tasks.json +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/resources/project/main.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/__init__.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/bin.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/crypto.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/debian.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/download.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/json.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/lib.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/math.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/mirror.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd/tasks/time.py +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd.egg-info/SOURCES.txt +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd.egg-info/dependency_links.txt +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd.egg-info/entry_points.txt +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd.egg-info/requires.txt +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/bcmd.egg-info/top_level.txt +0 -0
- {bcmd-0.5.3 → bcmd-0.5.5}/setup.cfg +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
__pycache__
|
|
2
|
-
*~$*
|
|
3
|
-
venv/
|
|
1
|
+
__pycache__
|
|
2
|
+
*~$*
|
|
3
|
+
venv/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files.exclude": {
|
|
3
|
-
".pytest_cache": true,
|
|
4
|
-
"**/__pycache__": true,
|
|
5
|
-
".gitignore": true,
|
|
6
|
-
".venv": true,
|
|
7
|
-
".venv-lock": true,
|
|
8
|
-
"venv": true,
|
|
9
|
-
},
|
|
10
|
-
"python.defaultInterpreterPath": "${workspaceFolder}/venv/Scripts/python.exe",
|
|
1
|
+
{
|
|
2
|
+
"files.exclude": {
|
|
3
|
+
".pytest_cache": true,
|
|
4
|
+
"**/__pycache__": true,
|
|
5
|
+
".gitignore": true,
|
|
6
|
+
".venv": true,
|
|
7
|
+
".venv-lock": true,
|
|
8
|
+
"venv": true,
|
|
9
|
+
},
|
|
10
|
+
"python.defaultInterpreterPath": "${workspaceFolder}/venv/Scripts/python.exe",
|
|
11
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
from pathlib import Path
|
|
2
3
|
from typing import Final
|
|
3
4
|
|
|
@@ -79,18 +80,48 @@ async def gen_init_py(
|
|
|
79
80
|
):
|
|
80
81
|
'递归生成 __init__.py 文件'
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
ignoreSubDirs = [
|
|
84
|
+
'.git',
|
|
85
|
+
'venv',
|
|
86
|
+
'node_modules',
|
|
87
|
+
'.pytest_cache',
|
|
88
|
+
'__pycache__',
|
|
89
|
+
'.vscode',
|
|
90
|
+
]
|
|
91
|
+
folderList = bpath.listDir(workspace_path, True)
|
|
92
|
+
# 剔除子目录是这些的文件 .git venv ...
|
|
93
|
+
folderList = [x for x in folderList if not any([y in x.parts for y in ignoreSubDirs])]
|
|
94
|
+
for folder in folderList:
|
|
95
|
+
pyInitFile = folder / '__init__.py'
|
|
96
|
+
if not pyInitFile.exists():
|
|
97
|
+
printYellow(pyInitFile)
|
|
98
|
+
await bfile.writeText(pyInitFile, '')
|
|
99
|
+
printGreen('OK')
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@app.command()
|
|
103
|
+
@syncCall
|
|
104
|
+
async def to_lf(
|
|
105
|
+
path: Path = typer.Option(None, '--path', help='指定目录或具体图片文件,默认当前目录'),
|
|
106
|
+
):
|
|
107
|
+
'将所有文件转换为 LF 格式'
|
|
108
|
+
ignoreSubDirs = [
|
|
109
|
+
'.git',
|
|
110
|
+
'venv',
|
|
111
|
+
'node_modules',
|
|
112
|
+
'.pytest_cache',
|
|
113
|
+
'__pycache__',
|
|
114
|
+
]
|
|
115
|
+
files = bpath.listFile(path, True)
|
|
116
|
+
# 剔除子目录是这些的文件 .git venv ...
|
|
117
|
+
files = [x for x in files if not any([y in x.parts for y in ignoreSubDirs])]
|
|
118
|
+
|
|
119
|
+
async def convertFile(file: Path):
|
|
120
|
+
try:
|
|
121
|
+
await bfile.toLf(file)
|
|
122
|
+
print(file)
|
|
123
|
+
except:
|
|
124
|
+
pass
|
|
125
|
+
|
|
126
|
+
await asyncio.gather(*[convertFile(file) for file in files])
|
|
96
127
|
printGreen('OK')
|
|
@@ -103,7 +103,7 @@ async def tiny(
|
|
|
103
103
|
pass
|
|
104
104
|
else:
|
|
105
105
|
# 要忽略掉的文件
|
|
106
|
-
bcolor.printYellow(f'{file.file}({file.compression}% /
|
|
106
|
+
bcolor.printYellow(f'{file.file}({file.compression - 100:.2f}% / 已压缩 / {file.getSizeDisplay()})')
|
|
107
107
|
fileList[i] = Null
|
|
108
108
|
fileList = [x for x in fileList if x]
|
|
109
109
|
|
|
@@ -140,6 +140,10 @@ class _TinyFile:
|
|
|
140
140
|
self._compression: float = 0.0
|
|
141
141
|
self._isTiny: bool = False
|
|
142
142
|
|
|
143
|
+
def getSizeDisplay(self):
|
|
144
|
+
size = bpath.get(self._file).stat().st_size / 1024
|
|
145
|
+
return f'{size:,.2f}KB'
|
|
146
|
+
|
|
143
147
|
async def updateInfo(self):
|
|
144
148
|
fileBytes = await bfile.readBytes(self._file)
|
|
145
149
|
self._compression = 0.0
|
|
@@ -194,8 +198,8 @@ class _TinyFile:
|
|
|
194
198
|
if isKeepOriginal:
|
|
195
199
|
outputFile = outputFile.with_stem(f'{outputFile.stem}_tiny')
|
|
196
200
|
bpath.move(tempFile, outputFile, True)
|
|
197
|
-
bcolor.printGreen(f'{outputFile}({outputCompression}% /
|
|
201
|
+
bcolor.printGreen(f'{outputFile}({outputCompression - 100:.2f}% / 压缩 / {self.getSizeDisplay()})')
|
|
198
202
|
else:
|
|
199
203
|
# 不进行压缩
|
|
200
204
|
await self._flushInfo(outputCompression, False)
|
|
201
|
-
bcolor.printMagenta(f'{self._file} ({outputCompression}% /
|
|
205
|
+
bcolor.printMagenta(f'{self._file} ({outputCompression - 100:.2f}% / 不处理 / {self.getSizeDisplay()})')
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Final
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
from beni import bcolor, binput, bpath, brun, btask
|
|
6
|
+
from beni.bfunc import syncCall
|
|
7
|
+
|
|
8
|
+
from ..common.func import useResources
|
|
9
|
+
from . import venv
|
|
10
|
+
|
|
11
|
+
app: Final = btask.newSubApp('项目相关')
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@app.command()
|
|
15
|
+
@syncCall
|
|
16
|
+
async def create_py(
|
|
17
|
+
path: Path = typer.Option(Path.cwd(), '--path', help='workspace 路径'),
|
|
18
|
+
):
|
|
19
|
+
'生成新项目'
|
|
20
|
+
|
|
21
|
+
# 检查目标路径是否合法
|
|
22
|
+
if path.exists():
|
|
23
|
+
if not path.is_dir():
|
|
24
|
+
bcolor.printRed('目标路径不是一个目录', path)
|
|
25
|
+
return
|
|
26
|
+
elif list(bpath.get(path).glob('*')):
|
|
27
|
+
bcolor.printRed('目标路径不是空目录', path)
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
bcolor.printYellow(path)
|
|
31
|
+
await binput.confirm('即将在此路径生成新项目,是否继续?')
|
|
32
|
+
venv.add(['benimang==now'], path)
|
|
33
|
+
with useResources('project') as sourceProjectPath:
|
|
34
|
+
bpath.copyOverwrite(sourceProjectPath, path)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@app.command()
|
|
38
|
+
@syncCall
|
|
39
|
+
async def install(
|
|
40
|
+
path: Path = typer.Option(Path.cwd(), '--path', help='初始化项目的路径'),
|
|
41
|
+
deep: int = typer.Option(3, '--deep', help='探索路径深度(默认:1)'),
|
|
42
|
+
):
|
|
43
|
+
'初始化项目(python项目执行beni venv install-lock / nodejs项目执行 pnpm install)'
|
|
44
|
+
|
|
45
|
+
async def checkPath(currentPath: Path, currentDeep: int):
|
|
46
|
+
for file in bpath.listFile(currentPath):
|
|
47
|
+
if file.name == '.venv':
|
|
48
|
+
with bpath.changePath(file.parent):
|
|
49
|
+
await brun.run('beni venv install-lock', isPrint=True)
|
|
50
|
+
return
|
|
51
|
+
elif file.name == 'package.json':
|
|
52
|
+
with bpath.changePath(file.parent):
|
|
53
|
+
await brun.run('pnpm install', isPrint=True)
|
|
54
|
+
return
|
|
55
|
+
if currentDeep < deep:
|
|
56
|
+
for folder in bpath.listPath(currentPath):
|
|
57
|
+
await checkPath(folder, currentDeep + 1)
|
|
58
|
+
|
|
59
|
+
await checkPath(path, 0)
|
|
@@ -6,7 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
from typing import Final
|
|
7
7
|
|
|
8
8
|
import typer
|
|
9
|
-
from beni import bcolor, bexecute, bfile, bhttp, bpath, btask
|
|
9
|
+
from beni import bcolor, bexecute, bfile, bhttp, bpath, brun, btask
|
|
10
10
|
from beni.bfunc import syncCall
|
|
11
11
|
from beni.btype import Null
|
|
12
12
|
from prettytable import PrettyTable
|
|
@@ -37,10 +37,11 @@ async def install_benimang(
|
|
|
37
37
|
path: Path = typer.Option(None, '--path', help='指定路径,默认当前目录'),
|
|
38
38
|
):
|
|
39
39
|
'更新 benimang 库,强制使用官方源'
|
|
40
|
+
pip = getPipFile(path)
|
|
41
|
+
await brun.run(f'{pip} install benimang -U -i https://pypi.org/simple', isPrint=True)
|
|
40
42
|
await _venv(
|
|
41
43
|
['benimang==now'],
|
|
42
44
|
path=path,
|
|
43
|
-
isOfficial=True,
|
|
44
45
|
)
|
|
45
46
|
|
|
46
47
|
|
|
@@ -90,7 +91,7 @@ async def _venv(
|
|
|
90
91
|
'python 虚拟环境配置'
|
|
91
92
|
btask.assertTrue(not (isUseBase == isUseLock == True), '2个选项只能选择其中一个 --use-base / --use-lock')
|
|
92
93
|
path = path or Path(os.getcwd())
|
|
93
|
-
venvPath =
|
|
94
|
+
venvPath = getVenvPath(path)
|
|
94
95
|
checkPathOrNotExists(venvPath)
|
|
95
96
|
venvFile = bpath.get(path, '.venv')
|
|
96
97
|
checkFileOrNotExists(venvFile)
|
|
@@ -115,15 +116,12 @@ async def _venv(
|
|
|
115
116
|
else:
|
|
116
117
|
installPackages = _mergePackageList(lockPackages or basePackages, packages)
|
|
117
118
|
installPackages = sorted(list(set(installPackages)))
|
|
118
|
-
|
|
119
|
-
pip = bpath.get(venvPath, 'Scripts/pip.exe')
|
|
120
|
-
else:
|
|
121
|
-
pip = bpath.get(venvPath, 'bin/pip')
|
|
119
|
+
pip = getPipFile(path)
|
|
122
120
|
await _pipInstall(pip, installPackages, isOfficial)
|
|
123
121
|
with bpath.useTempFile() as tempFile:
|
|
124
122
|
await bexecute.run(f'{pip} freeze > {tempFile}')
|
|
125
123
|
basePackages = _mergePackageList(basePackages, packages)
|
|
126
|
-
lockPackages = (await bfile.readText(tempFile)).strip().split('\n')
|
|
124
|
+
lockPackages = (await bfile.readText(tempFile)).replace('\r\n', '\n').strip().split('\n')
|
|
127
125
|
await updatePackageList(venvFile, basePackages, lockPackages)
|
|
128
126
|
bcolor.printGreen('OK')
|
|
129
127
|
|
|
@@ -215,3 +213,14 @@ def _getPackageName(package: str):
|
|
|
215
213
|
if package.startswith('#'):
|
|
216
214
|
package = package.replace('#', '', 1).strip()
|
|
217
215
|
return package
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def getVenvPath(path: Path):
|
|
219
|
+
return bpath.get(path, 'venv')
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def getPipFile(path: Path):
|
|
223
|
+
if sys.platform.startswith('win'):
|
|
224
|
+
return bpath.get(getVenvPath(path), 'Scripts/pip.exe')
|
|
225
|
+
else:
|
|
226
|
+
return bpath.get(getVenvPath(path), 'bin/pip')
|
bcmd-0.5.3/bcmd/tasks/project.py
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from typing import Final
|
|
3
|
-
|
|
4
|
-
import typer
|
|
5
|
-
from beni import bcolor, binput, bpath, btask
|
|
6
|
-
from beni.bfunc import syncCall
|
|
7
|
-
|
|
8
|
-
from ..common.func import useResources
|
|
9
|
-
from .venv import add as venvAdd
|
|
10
|
-
|
|
11
|
-
app: Final = btask.app
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@app.command('project')
|
|
15
|
-
@syncCall
|
|
16
|
-
async def _(
|
|
17
|
-
path: Path = typer.Option(Path.cwd(), '--path', help='workspace 路径'),
|
|
18
|
-
):
|
|
19
|
-
'生成新项目'
|
|
20
|
-
|
|
21
|
-
# 检查目标路径是否合法
|
|
22
|
-
if path.exists():
|
|
23
|
-
if not path.is_dir():
|
|
24
|
-
bcolor.printRed('目标路径不是一个目录', path)
|
|
25
|
-
return
|
|
26
|
-
elif list(bpath.get(path).glob('*')):
|
|
27
|
-
bcolor.printRed('目标路径不是空目录', path)
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
bcolor.printYellow(path)
|
|
31
|
-
await binput.confirm('即将在此路径生成新项目,是否继续?')
|
|
32
|
-
venvAdd(['benimang'], path)
|
|
33
|
-
with useResources('project') as sourceProjectPath:
|
|
34
|
-
bpath.copyOverwrite(sourceProjectPath, path)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|