Skip to main content

Python utilities for dynamic strings, sandboxed files, multiuse-case classes, and ANSI colors

Project description

ltoolboxLib

A Swiss Army knife for Python scripting and automation

PyPI version

ltoolboxLib is a powerful utility library for Python that simplifies file operations, text manipulation, encoding, system tasks, and more, with built-in sandbox mode for safe testing.


Features

  • File Operations - Read, write, copy, grep, and manage files (with sandbox support).
  • Dynamic Strings - S() and M() for runtime string interpolation.
  • Encoding/Decoding - Secure encode()/decode() with shadow keys.
  • System Utilities - Cross-platform notifications, clipboard access, and public IP fetching.
  • ANSI Styling - RGB colors and text formatting for terminals.
  • Sandbox Mode - Virtual filesystem for testing without touching real files.
  • Smart Functions - Fuzzy matching, random generators, UUIDs, and more.
  • Temporary Variables - Values that expire over time, after use, or permanently transform.
  • Debugging Tools - Tracebacks, watches, pauses, and safe evaluations.
  • Utility Classes - Including Toggle, Undo, and Lock for stateful logic and memory control.

Quick Start

1. File Operations (Sandbox Supported)

from ltoolboxLib import *

debug.sandbox(True)
rw_file("test.txt", "Hello, sandbox!")
print(file_exists("test.txt"))  # True (in sandbox)

debug.sandbox(False)
rw_file("real_file.txt", "This writes to disk.")

2. Dynamic Strings (S and M)

user = "Alice"
id_num = 42

greeting = S("User {user} (ID: {id_num}) logged in at {timestamp()}")
m_greeting = M("User {user} (ID: [id_num]) logged in at {timestamp()}")

user = "Bob"
id_num = 99

print(greeting)     # User Bob (ID: 99) ...
print(m_greeting)   # User Bob (ID: 42) ...

3. Encoding & Security

encoded = encode("Secret Message")
decoded = decode(encoded)
print(decoded.decode())

4. System Utilities

notify("Done!", "Script complete!")
clipboard_copy("Text copied.")
print(censor(get_public_ip(), '-'))  # "118.---.---.93"

5. Temporary Variables

t = Temporary("Code: 1337", delay=5, expiry="Expired")
print(t)  # "Code: 1337"
time.sleep(5)
print(t)  # "Expired"

t2 = Temporary("Limited use", uses=2, expiry="Gone")
print(t2)  # "Limited use"
print(t2)  # "Limited use"
print(t2)  # "Gone"

6. Other Classes

Toggle("A", "B", "C")  # Cycles through values
Undo("Initial").set("Change 1").undo()  # Reverts
Lock("Secret").lock().set("Still secret")  # Cannot overwrite if locked

7. Run the Full Demo

tech_demo()  # Try it all in one shot

API Highlights

Function/Class Description
rw_file() Read/write files (sandbox-aware).
S() / M() Dynamic and static-evaluated strings.
encode() / decode() Secure encoding with shadow keys.
notify() OS-level notification popup.
file_grep() Regex search across files.
ansi() RGB terminal styling.
debug.sandbox() Toggle sandbox mode.
Temporary() Create time/use-expiring or permanent-transform values.
Toggle() Cycle between given values.
Undo() Versioned string that supports undo/redo/history.
Lock() Prevent changes unless explicitly unlocked.

DEBUG Features

debug.sandbox(True/False)        # Enable/disable sandbox
debug.death(True/False)          # Enable/disable forced errors
debug.status()                   # Show sandbox and death state
debug.peek_vars(dict, keys=None) # View contents of variables
debug.safe_eval(expr, ...)       # Evaluate expressions safely
debug.trace(msg="Trace")         # Print a trace stack
debug.pause("...")               # Pause execution
debug.watch("myVar", globals())  # Watch variable value

Why Use ltoolboxLib?

  • All-in-One Utility - A single import covers dozens of use cases.
  • Safe Testing - Sandbox mode protects your real files.
  • Smarter Code - Logic and flow tools like Toggle, Undo, and Temporary.
  • Pretty Output - Styled output for terminal nerds.
  • Quick Start, Quick Results - Minimal setup, maximum value.
  • Batteries included - Not really though. No batteries.

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

ltoolboxlib-1.0.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

ltoolboxlib-1.0.1-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file ltoolboxlib-1.0.1.tar.gz.

File metadata

  • Download URL: ltoolboxlib-1.0.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for ltoolboxlib-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8c09b98ffbcd5cab45f0e20865b52ad257184263e8e6e7afd82f68efee5b82c7
MD5 b5163646db2482677fb0fba28f26da02
BLAKE2b-256 c3d4717c5c3ff6a1d47cdd0cc1b799d70db3c85eb987080ad826ab7c54bb8775

See more details on using hashes here.

File details

Details for the file ltoolboxlib-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ltoolboxlib-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for ltoolboxlib-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b82e7a352954bdc5ce78308220bd0a1418df689b814989a6433f99ab5fdb854a
MD5 1799cce0ca182ef061675d8d54c701cc
BLAKE2b-256 d4c1a791b4c305a9aedc38eed59149d50112d05ae54a91bf448ad3e9c6f6217d

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