A packge of utils or tools keeps Python sweet.
Project description
naotool
🍬A packge of utils or tools keeps Python sweet.
快速上手
pip install naotool
最佳实践
from naotool import deco
@deco.compat_arg_error
def f():
pass
f(1, 2, 3, a=1)
print("ok!")
""" 最佳实践,把一个文件夹内的 .jpg 都重命名为:{md5}.jpg"""
import asyncio
import os
from pathlib import Path
from PIL import Image
from naotool.img.op import img_md5hex
from naotool.img import get
Image.MAX_IMAGE_PIXELS = None
img_dir = Path(r"../../imgs/")
img_name_list = filter(lambda x: x.endswith(".jpg"), os.listdir(str(img_dir)))
path_list = [img_dir / name for name in img_name_list]
async def main():
[
os.rename(
src,
os.path.join(
img_dir.absolute(),
f"{img_md5hex(await get(src))}.{os.path.splitext(src)[1]}",
),
)
for src in path_list
]
asyncio.run(main())
tools
module | example | description |
---|---|---|
img | get() | get 图片 |
deco | @deco.compat_arg_error() | 装饰器 |
httpn | AutoCloseAsyncClient(auto_close_time=3) | 会话自动关闭,严格规范代理 |
exception | NOException | 自定义异常 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
naotool-0.1.8.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file naotool-0.1.8.tar.gz
.
File metadata
- Download URL: naotool-0.1.8.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d814539860f5eb5b79f71b9a9ef0affecd386268e0a997f71f8d82f98f9a75e6 |
|
MD5 | 3ceef3763fb7de35c049fc95e256b764 |
|
BLAKE2b-256 | 311611c7dfd78f4040357918914e18febd9316a70e44be60b6d5a50e6c7efde3 |
File details
Details for the file naotool-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: naotool-0.1.8-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1611887576fe6b5a97a36f0ff74cc326bfea9d7df85fcad7320a4ce25cfd1d8 |
|
MD5 | 143723bce38011dbcc89ebcdd1b28d66 |
|
BLAKE2b-256 | 35b5d16117ad79746ab1c91b68a19ffd4ccca82a4ce8567efbb4572e54b76b03 |