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 rename_image(src: Path):
try:
md5 = img_md5hex(await get(str(src)))
new_path = img_dir / f"{md5}{src.suffix}"
os.rename(src, new_path)
except Exception as e:
print(f"Failed to process {src}: {e}")
async def main():
await asyncio.gather(*(rename_image(src) for src in path_list))
asyncio.run(main())
tools
module | example | description |
---|---|---|
img | get("http://img.png") | 图片 |
deco | @deco.compat_arg_error() | 装饰器 |
httpn | AutoCloseAsyncClient(auto_close_time=3) | 更简洁的 http |
cls | copy_attr(a, b) | SpringBean (?) |
strs | tight("delete b l a n k char") | 你的字符串有点松弛 |
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.12.tar.gz
(7.9 kB
view details)
Built Distribution
naotool-0.1.12-py3-none-any.whl
(10.9 kB
view details)
File details
Details for the file naotool-0.1.12.tar.gz
.
File metadata
- Download URL: naotool-0.1.12.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fafcc3d377b178686718f8e86c1cbd2e14df35f7e580fcc1f91a9d9eadc28ad4 |
|
MD5 | 118def338b0c4c1627042f3e60414f83 |
|
BLAKE2b-256 | 34881af0521535b636948a94f99bad8cf158fe27375f5b37584f1f69cf3a3df8 |
File details
Details for the file naotool-0.1.12-py3-none-any.whl
.
File metadata
- Download URL: naotool-0.1.12-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c74c5a91a57fd82f13939d4df71e489598a9a930cbbeedbf95e40434805796c4 |
|
MD5 | 1cda4f954847b306d17a9282f3632549 |
|
BLAKE2b-256 | 1a77ef5a9665eb36eeeadbe868cea95b6ada447405bca876db831419c67e4379 |