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

Uploaded Source

Built Distribution

naotool-0.1.9-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: naotool-0.1.9.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.9.tar.gz
Algorithm Hash digest
SHA256 79c8b253869d68f64c64d27e287684d7625900eafe67fadd391a010e3ff7e7a0
MD5 6665459f2c64d42c9103a62b96fca1b0
BLAKE2b-256 6e585b518d7e502e76946cadc5cec87b65546a32b1827e8cf66f27bf01d66205

See more details on using hashes here.

File details

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

File metadata

  • Download URL: naotool-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 10.1 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 1a4479fd4f341b66974b0e2133bde713a2e22a2c346f9838819d3ec0fc8ae72f
MD5 0bda045a2bfdc6e56ad87bd95de1dc7b
BLAKE2b-256 f45b8648399ee1fef91cb063090a4629344af8567c541790fd02367758882d79

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