Metadata-Version: 2.4
Name: py-abu
Version: 1.3.8
Summary: A small personal Python utility toolkit for automation scripts
Author-email: Chris <10512@qq.com>
License: MIT
Project-URL: Homepage, https://github.com/ChrisYP/abu
Project-URL: Repository, https://github.com/ChrisYP/abu
Project-URL: Issues, https://github.com/ChrisYP/abu/issues
Keywords: abu,utility,toolkit,crypto,notify
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: loguru>=0.7.0
Requires-Dist: pyperclip>=1.8.0
Requires-Dist: curl_cffi>=0.5.0
Requires-Dist: Brotli>=1.0.0
Requires-Dist: msoffcrypto-tool>=5.0.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: openpyxl>=3.1.0
Requires-Dist: cryptography>=41.0.0
Dynamic: license-file

# py-abu

`py-abu` is a small Python utility toolkit for personal automation scripts. It keeps common helpers in one package: text extraction, hashing and AES encryption, TOTP codes, notifications, clipboard utilities, timers, and password-protected Excel reads.

The project is intentionally lightweight. APIs are kept flat so scripts can continue to use simple imports such as `from abu import text_mid`.

## Installation

```bash
pip install py-abu
```

Python 3.8+ is supported.

## Quick Start

```python
from abu import VariantAES, get_2fa, text_mid, text_random_str

token = text_mid("token=abc123;", "token=", ";")
name = text_random_str(8)
code = get_2fa("JBSWY3DPEHPK3PXP")

crypto = VariantAES("password")
encrypted = crypto.encrypt("hello")
plain_text = crypto.decrypt(encrypted)
```

## What Is Included

| Area | Helpers |
| --- | --- |
| Text | `text_mid`, `text_mid_batch`, `text_random_str` |
| Crypto | `crypto_md5`, `crypto_sha1`, `crypto_sha256`, `crypto_sha512`, `crypto_hmac_md5`, `VariantAES` |
| 2FA | `get_2fa` |
| Notifications | `send_msg_to_telegram`, `send_msg_to_bark`, `QQ` |
| Excel | `open_excel_with_columns`, `open_excel_single_text` |
| Utilities | `json_to_object`, `flatten_list`, `set_timeout`, clipboard helpers, cookie-to-Chrome helper |

## Examples

### Text Extraction

```python
from abu import text_mid, text_mid_batch

html = "<a>one</a><a>two</a>"

first = text_mid(html, "<a>", "</a>")
all_items = text_mid_batch(html, "<a>", "</a>")
```

### Hashing

```python
from abu import crypto_md5, crypto_sha256, crypto_hmac_md5

crypto_md5("hello")
crypto_sha256("hello")
crypto_hmac_md5("secret", "hello")
```

### AES Encryption

```python
from abu import VariantAES

aes = VariantAES("my-password")
cipher_text = aes.encrypt("private text")
plain_text = aes.decrypt(cipher_text)
```

`VariantAES.encrypt()` returns a hex string containing `salt + iv + ciphertext`, so the same password can decrypt it later.

### Telegram And Bark

```python
from abu import send_msg_to_bark, send_msg_to_telegram

send_msg_to_bark("https://api.day.app/YOUR_KEY", title="Done", body="Task finished")
send_msg_to_telegram("BOT_TOKEN", 123456789, "Task finished")
```

### Password-Protected Excel

```python
from abu import open_excel_single_text, open_excel_with_columns

pairs = open_excel_with_columns("secret.xlsx", "password", address_col=0, key_col=1)
first_row = open_excel_single_text("secret.xlsx", "password", lines=2)
```

## Development

```bash
python -m compileall abu
python -m build
twine check dist/*
```

## License

MIT
