Skip to main content

A packge of utils or tools keeps Python sweet.

Project description

naotool

✨ 🍬A packge of utils or tools keeps Python sweet. 让 py 保持甜甜的 ✨

license:MIT pypi python:3.10+

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() get 图片
deco @deco.compat_arg_error() 装饰器
httpn AutoCloseAsyncClient(auto_close_time=3) 会话自动关闭,严格规范代理
exception NOException 自定义异常

Project details


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.11.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

naotool-0.1.11-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file naotool-0.1.11.tar.gz.

File metadata

  • Download URL: naotool-0.1.11.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.1 Windows/10

File hashes

Hashes for naotool-0.1.11.tar.gz
Algorithm Hash digest
SHA256 17b51b16897c8ad4735b6746b8b862e3ad7e3373719ef711e01952abb7e681ff
MD5 dbd5cb728b68a7f0c73de8e447a43298
BLAKE2b-256 3e2a42c86a897409e28b06c140b1d26d2ebd80728829a5fc96eba1d744a34d5e

See more details on using hashes here.

File details

Details for the file naotool-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: naotool-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.1 Windows/10

File hashes

Hashes for naotool-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 cd98a63a8517c6435d19b0def9ddd96b8d40b5f6ae198d84774d2ccb26177c00
MD5 6afae58fd48e9e2c31e188e45e7ffb3f
BLAKE2b-256 4073b782f1ec1dd17406aa83180d5c8a737475946b24ac76d0547ddd6c234888

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page