autobeni 1.0.0__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.
- autobeni-1.0.0/MANIFEST.in +2 -0
- autobeni-1.0.0/PKG-INFO +27 -0
- autobeni-1.0.0/README.md +1 -0
- autobeni-1.0.0/autobeni/__init__.py +7 -0
- autobeni-1.0.0/autobeni/common/__init__.py +0 -0
- autobeni-1.0.0/autobeni/tasks/__init__.py +5 -0
- autobeni-1.0.0/autobeni/tasks/hello.py +8 -0
- autobeni-1.0.0/autobeni/tasks/time.py +80 -0
- autobeni-1.0.0/autobeni.egg-info/PKG-INFO +27 -0
- autobeni-1.0.0/autobeni.egg-info/SOURCES.txt +23 -0
- autobeni-1.0.0/autobeni.egg-info/dependency_links.txt +1 -0
- autobeni-1.0.0/autobeni.egg-info/entry_points.txt +2 -0
- autobeni-1.0.0/autobeni.egg-info/requires.txt +20 -0
- autobeni-1.0.0/autobeni.egg-info/top_level.txt +3 -0
- autobeni-1.0.0/pyproject.toml +49 -0
- autobeni-1.0.0/setup.cfg +4 -0
- autobeni-1.0.0/test/__init__.py +0 -0
- autobeni-1.0.0/test/conftest.py +17 -0
- autobeni-1.0.0/test/test_pdf.py +43 -0
- autobeni-1.0.0/test/test_time.py +10 -0
autobeni-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autobeni
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Commands for Beni
|
|
5
|
+
Author-email: Beni Mang <benimang@126.com>
|
|
6
|
+
Maintainer-email: Beni Mang <benimang@126.com>
|
|
7
|
+
Keywords: benimang,beni,autobeni
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: aioconsole>=0.8.1
|
|
10
|
+
Requires-Dist: async-lru>=2.0.5
|
|
11
|
+
Requires-Dist: benimang>=1.0.1
|
|
12
|
+
Requires-Dist: cryptography>=45.0.4
|
|
13
|
+
Requires-Dist: paramiko>=3.5.1
|
|
14
|
+
Requires-Dist: pillow>=11.2.1
|
|
15
|
+
Requires-Dist: playwright>=1.57.0
|
|
16
|
+
Requires-Dist: prettytable>=3.16.0
|
|
17
|
+
Requires-Dist: pymupdf>=1.26.1
|
|
18
|
+
Requires-Dist: qiniu>=7.16.0
|
|
19
|
+
Requires-Dist: typer>=0.16.0
|
|
20
|
+
Requires-Dist: chardet==5.2.0
|
|
21
|
+
Requires-Dist: json5>=0.13.0
|
|
22
|
+
Provides-Extra: full
|
|
23
|
+
Requires-Dist: img2pdf>=0.6.1; extra == "full"
|
|
24
|
+
Requires-Dist: pytest>=8.4.0; extra == "full"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=1.0.0; extra == "full"
|
|
26
|
+
Requires-Dist: pytest-order>=1.3.0; extra == "full"
|
|
27
|
+
Requires-Dist: ruff>=0.15.5; extra == "full"
|
autobeni-1.0.0/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Commands for autobeni
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from datetime import datetime as Datetime
|
|
3
|
+
from datetime import timezone
|
|
4
|
+
from zoneinfo import ZoneInfo
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
|
|
8
|
+
from beni import bcolor, btask
|
|
9
|
+
from beni.bfunc import split_lines, sync_call
|
|
10
|
+
from beni.btype import Null
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@btask.command('time')
|
|
14
|
+
@sync_call
|
|
15
|
+
async def show_time(
|
|
16
|
+
args: list[str] = typer.Argument(None),
|
|
17
|
+
):
|
|
18
|
+
"""
|
|
19
|
+
格式化时间戳\n
|
|
20
|
+
beni time\n
|
|
21
|
+
beni time 1632412740\n
|
|
22
|
+
beni time 1632412740.1234\n
|
|
23
|
+
beni time 2021-9-23\n
|
|
24
|
+
beni time 2021-9-23 09:47:00\n
|
|
25
|
+
"""
|
|
26
|
+
args = args or []
|
|
27
|
+
btask.assert_true(len(args) <= 2, '参数过多')
|
|
28
|
+
value1: str | None = args[0] if len(args) >= 1 else None
|
|
29
|
+
value2: str | None = args[1] if len(args) >= 2 else None
|
|
30
|
+
timestamp: float = Null
|
|
31
|
+
if not value1:
|
|
32
|
+
timestamp = time.time()
|
|
33
|
+
else:
|
|
34
|
+
try:
|
|
35
|
+
timestamp = float(value1)
|
|
36
|
+
except Exception:
|
|
37
|
+
try:
|
|
38
|
+
if value2:
|
|
39
|
+
timestamp = Datetime.strptime(f'{value1} {value2}', '%Y-%m-%d %H:%M:%S').timestamp()
|
|
40
|
+
else:
|
|
41
|
+
timestamp = Datetime.strptime(f'{value1}', '%Y-%m-%d').timestamp()
|
|
42
|
+
except Exception:
|
|
43
|
+
pass
|
|
44
|
+
if not timestamp:
|
|
45
|
+
bcolor.print_red('参数无效\n')
|
|
46
|
+
bcolor.print_red('使用示例:')
|
|
47
|
+
msg_ary = split_lines(str(show_time.__doc__))[1:]
|
|
48
|
+
bcolor.print_red('\n'.join(msg_ary))
|
|
49
|
+
return
|
|
50
|
+
print()
|
|
51
|
+
bcolor.print_magenta(timestamp)
|
|
52
|
+
print()
|
|
53
|
+
# localtime = time.localtime(timestamp)
|
|
54
|
+
# tzname = time.tzname[(time.daylight and localtime.tm_isdst) and 1 or 0]
|
|
55
|
+
# bcolor.printx(time.strftime('%Y-%m-%d %H:%M:%S %z', localtime), tzname, colors=[Fore.YELLOW])
|
|
56
|
+
# print()
|
|
57
|
+
datetime_utc = Datetime.fromtimestamp(timestamp, tz=timezone.utc)
|
|
58
|
+
tzname_list = [
|
|
59
|
+
'Australia/Sydney',
|
|
60
|
+
'Asia/Tokyo',
|
|
61
|
+
'Asia/Shanghai',
|
|
62
|
+
'Asia/Kolkata',
|
|
63
|
+
'Africa/Cairo',
|
|
64
|
+
'Europe/London',
|
|
65
|
+
'America/Sao_Paulo',
|
|
66
|
+
'America/New_York',
|
|
67
|
+
'America/Chicago',
|
|
68
|
+
'America/Los_Angeles',
|
|
69
|
+
]
|
|
70
|
+
for tzname in tzname_list:
|
|
71
|
+
datetime_tz = datetime_utc.astimezone(ZoneInfo(tzname))
|
|
72
|
+
dst_str = ''
|
|
73
|
+
dst = datetime_tz.dst()
|
|
74
|
+
if dst:
|
|
75
|
+
dst_str = f'(DST+{dst})'
|
|
76
|
+
if tzname == 'Asia/Shanghai':
|
|
77
|
+
bcolor.print_yellow(f'{datetime_tz} {tzname} {dst_str}')
|
|
78
|
+
else:
|
|
79
|
+
print(f'{datetime_tz} {tzname} {dst_str}')
|
|
80
|
+
print()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autobeni
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Commands for Beni
|
|
5
|
+
Author-email: Beni Mang <benimang@126.com>
|
|
6
|
+
Maintainer-email: Beni Mang <benimang@126.com>
|
|
7
|
+
Keywords: benimang,beni,autobeni
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: aioconsole>=0.8.1
|
|
10
|
+
Requires-Dist: async-lru>=2.0.5
|
|
11
|
+
Requires-Dist: benimang>=1.0.1
|
|
12
|
+
Requires-Dist: cryptography>=45.0.4
|
|
13
|
+
Requires-Dist: paramiko>=3.5.1
|
|
14
|
+
Requires-Dist: pillow>=11.2.1
|
|
15
|
+
Requires-Dist: playwright>=1.57.0
|
|
16
|
+
Requires-Dist: prettytable>=3.16.0
|
|
17
|
+
Requires-Dist: pymupdf>=1.26.1
|
|
18
|
+
Requires-Dist: qiniu>=7.16.0
|
|
19
|
+
Requires-Dist: typer>=0.16.0
|
|
20
|
+
Requires-Dist: chardet==5.2.0
|
|
21
|
+
Requires-Dist: json5>=0.13.0
|
|
22
|
+
Provides-Extra: full
|
|
23
|
+
Requires-Dist: img2pdf>=0.6.1; extra == "full"
|
|
24
|
+
Requires-Dist: pytest>=8.4.0; extra == "full"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=1.0.0; extra == "full"
|
|
26
|
+
Requires-Dist: pytest-order>=1.3.0; extra == "full"
|
|
27
|
+
Requires-Dist: ruff>=0.15.5; extra == "full"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
./autobeni/__init__.py
|
|
5
|
+
./autobeni/common/__init__.py
|
|
6
|
+
./autobeni/tasks/__init__.py
|
|
7
|
+
./autobeni/tasks/hello.py
|
|
8
|
+
./autobeni/tasks/time.py
|
|
9
|
+
./test/__init__.py
|
|
10
|
+
./test/conftest.py
|
|
11
|
+
./test/test_pdf.py
|
|
12
|
+
./test/test_time.py
|
|
13
|
+
autobeni/__init__.py
|
|
14
|
+
autobeni.egg-info/PKG-INFO
|
|
15
|
+
autobeni.egg-info/SOURCES.txt
|
|
16
|
+
autobeni.egg-info/dependency_links.txt
|
|
17
|
+
autobeni.egg-info/entry_points.txt
|
|
18
|
+
autobeni.egg-info/requires.txt
|
|
19
|
+
autobeni.egg-info/top_level.txt
|
|
20
|
+
autobeni/common/__init__.py
|
|
21
|
+
autobeni/tasks/__init__.py
|
|
22
|
+
autobeni/tasks/hello.py
|
|
23
|
+
autobeni/tasks/time.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
aioconsole>=0.8.1
|
|
2
|
+
async-lru>=2.0.5
|
|
3
|
+
benimang>=1.0.1
|
|
4
|
+
cryptography>=45.0.4
|
|
5
|
+
paramiko>=3.5.1
|
|
6
|
+
pillow>=11.2.1
|
|
7
|
+
playwright>=1.57.0
|
|
8
|
+
prettytable>=3.16.0
|
|
9
|
+
pymupdf>=1.26.1
|
|
10
|
+
qiniu>=7.16.0
|
|
11
|
+
typer>=0.16.0
|
|
12
|
+
chardet==5.2.0
|
|
13
|
+
json5>=0.13.0
|
|
14
|
+
|
|
15
|
+
[full]
|
|
16
|
+
img2pdf>=0.6.1
|
|
17
|
+
pytest>=8.4.0
|
|
18
|
+
pytest-asyncio>=1.0.0
|
|
19
|
+
pytest-order>=1.3.0
|
|
20
|
+
ruff>=0.15.5
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# https://peps.python.org/pep-0621/#example
|
|
2
|
+
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#declaring-project-metadata
|
|
3
|
+
|
|
4
|
+
[project]
|
|
5
|
+
name = 'autobeni'
|
|
6
|
+
version = '1.0.0'
|
|
7
|
+
description = 'Commands for Beni'
|
|
8
|
+
requires-python = '>=3.10'
|
|
9
|
+
keywords = ['benimang', 'beni', 'autobeni']
|
|
10
|
+
authors = [{ name = 'Beni Mang', email = 'benimang@126.com' }]
|
|
11
|
+
maintainers = [{ name = 'Beni Mang', email = 'benimang@126.com' }]
|
|
12
|
+
|
|
13
|
+
dependencies = [
|
|
14
|
+
"aioconsole>=0.8.1",
|
|
15
|
+
"async-lru>=2.0.5",
|
|
16
|
+
"benimang>=1.0.1",
|
|
17
|
+
"cryptography>=45.0.4",
|
|
18
|
+
"paramiko>=3.5.1",
|
|
19
|
+
"pillow>=11.2.1",
|
|
20
|
+
"playwright>=1.57.0",
|
|
21
|
+
"prettytable>=3.16.0",
|
|
22
|
+
"pymupdf>=1.26.1",
|
|
23
|
+
"qiniu>=7.16.0",
|
|
24
|
+
"typer>=0.16.0",
|
|
25
|
+
"chardet==5.2.0", # 升级到 6.0 版本后导致和 qiniu 里面的引用不匹配
|
|
26
|
+
"json5>=0.13.0",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
full = [
|
|
31
|
+
"img2pdf>=0.6.1",
|
|
32
|
+
"pytest>=8.4.0",
|
|
33
|
+
"pytest-asyncio>=1.0.0",
|
|
34
|
+
"pytest-order>=1.3.0",
|
|
35
|
+
"ruff>=0.15.5",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
autobeni = 'autobeni:run'
|
|
40
|
+
|
|
41
|
+
[tool.uv]
|
|
42
|
+
package = true
|
|
43
|
+
|
|
44
|
+
[tool.setuptools]
|
|
45
|
+
package-dir = { "" = "." }
|
|
46
|
+
|
|
47
|
+
[[tool.uv.index]]
|
|
48
|
+
url = "https://mirrors.aliyun.com/pypi/simple"
|
|
49
|
+
default = true
|
autobeni-1.0.0/setup.cfg
ADDED
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# '''
|
|
2
|
+
# 快捷键(默认)
|
|
3
|
+
# CTRL+; A 执行全部单元测试
|
|
4
|
+
# CTRL+; E 只执行上次出错的用例
|
|
5
|
+
# CTRL+; C 清除结果
|
|
6
|
+
# CTRL+; CTRL+A 调试全部单元测试
|
|
7
|
+
# CTRL+; CTRL+E 只调试上次出错的用例
|
|
8
|
+
# '''
|
|
9
|
+
|
|
10
|
+
import pytest_asyncio
|
|
11
|
+
|
|
12
|
+
from autobeni.tasks import * # noqa: F403
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest_asyncio.fixture(scope='session', autouse=True) # type: ignore
|
|
16
|
+
def prepare_session():
|
|
17
|
+
yield
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from contextlib import asynccontextmanager
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
import img2pdf
|
|
6
|
+
import pytest
|
|
7
|
+
from PIL import Image
|
|
8
|
+
|
|
9
|
+
from beni import bfile, bpath, btask
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.mark.asyncio
|
|
13
|
+
async def test_pdf_output_images():
|
|
14
|
+
async with _create_temp_pdf_file() as pdf_file:
|
|
15
|
+
result = await btask.test_call('pdf', 'output-images', '--target', pdf_file.as_posix())
|
|
16
|
+
assert result.exit_code == 0
|
|
17
|
+
output_images_path = pdf_file.parent / f'{pdf_file.stem}-PDF图片文件'
|
|
18
|
+
assert output_images_path.is_dir()
|
|
19
|
+
assert len(list(output_images_path.glob('*.png'))) == 1
|
|
20
|
+
assert len(list(output_images_path.glob('*.jpeg'))) == 1
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@asynccontextmanager
|
|
24
|
+
async def _create_temp_pdf_file():
|
|
25
|
+
|
|
26
|
+
def create_color_block_image(file: Path, color: tuple[int, int, int], size: tuple[int, int] = (500, 500), image_format: Literal['JPEG', 'PNG'] = 'JPEG'):
|
|
27
|
+
image = Image.new('RGB', size, color)
|
|
28
|
+
image.save(file, format=image_format)
|
|
29
|
+
image.close()
|
|
30
|
+
return file
|
|
31
|
+
|
|
32
|
+
with bpath.use_temp_path(True) as temp_path:
|
|
33
|
+
# 创建色块图片
|
|
34
|
+
file_list = [
|
|
35
|
+
create_color_block_image(temp_path / 'blue.png', (0, 0, 255), image_format='PNG'),
|
|
36
|
+
create_color_block_image(temp_path / 'red.jpeg', (255, 0, 0), image_format='JPEG'),
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
# 生成PDF文件
|
|
40
|
+
pdf_file = temp_path / 'output.pdf'
|
|
41
|
+
await bfile.write_bytes(pdf_file, img2pdf.convert(file_list)) # type: ignore
|
|
42
|
+
|
|
43
|
+
yield pdf_file
|