Skip to main content

A small personal Python utility toolkit for automation scripts

Project description

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

pip install py-abu

Python 3.8+ is supported.

Quick Start

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

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

from abu import crypto_md5, crypto_sha256, crypto_hmac_md5

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

AES Encryption

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

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

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

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

License

MIT

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

py_abu-1.3.8.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_abu-1.3.8-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file py_abu-1.3.8.tar.gz.

File metadata

  • Download URL: py_abu-1.3.8.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for py_abu-1.3.8.tar.gz
Algorithm Hash digest
SHA256 747e91c7741e541faa00e31cd93af21196db51be7192858bcec9ba1160d74a88
MD5 6e8c0178bb448c8dc8f901dbd3c1acc4
BLAKE2b-256 6db7daf57e6b1011afc442b646a7d45a6fc5479dba941840fd89ac8639f58105

See more details on using hashes here.

File details

Details for the file py_abu-1.3.8-py3-none-any.whl.

File metadata

  • Download URL: py_abu-1.3.8-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for py_abu-1.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 150b4dad2504e622d7f70a609bc4de8da7cfcb176340983c5fd664c1f44e47b1
MD5 8a8e84513ca2850da3d9e97869732e8e
BLAKE2b-256 5e3723aaef5eba02863d5b8826e0759f1c4fc38c742c15d0db2147238ae758cf

See more details on using hashes here.

Supported by

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