Documentation

Complete guide to using PyWizardry in your projects

🚀 Getting Started

PyWizardry is designed to be intuitive and easy to use. Here's how to get started in minutes.

Quick Start

# Basic installation
pip install PyWizardry

# Import the library
import pywizardry as pw

# Create a wizard instance
wiz = pw.Wizard()

# Start using utilities
files = wiz.files.find("*.py")
slug = wiz.strings.slugify("Hello World!")
password = wiz.strings.password()

📦 Installation

System Requirements

  • Python: 3.7 or higher
  • Operating System: Windows, macOS, Linux
  • Memory: 128MB RAM minimum
  • Dependencies: Zero required dependencies

Installation Methods

PyPI (Recommended)

pip install PyWizardry

From Source

git clone https://github.com/saifullah10141/pywizardry.git
cd pywizardry
pip install -e .

With Optional Features

pip install PyWizardry[full]

Includes Pillow, psutil, aiohttp

🎯 Basic Usage

Importing the Library

# Import everything
import pywizardry as pw

# Import specific modules
from pywizardry import Wizard
from pywizardry.files import FileMagic
from pywizardry.strings import StringSorcery

Creating a Wizard Instance

# Default wizard with all features
wiz = pw.Wizard()

# Custom configuration
wiz = pw.Wizard(
    enable_logging=True,
    log_level="INFO",
    enable_cache=True,
    cache_size=1000,
    color_output=True
)

Module Structure

Module Access Description
wiz.files FileMagic File system operations
wiz.strings StringSorcery String manipulation
wiz.security SecuritySpells Security utilities
wiz.dates TimeWizardry Date/time utilities
wiz.network NetworkEnchantments Network operations
wiz.data DataAlchemy Data processing

⚙️ Configuration

Configuration File

Create a pywizardry_config.json file in your project root:

{
    "logging": {
        "level": "INFO",
        "file": "logs/pywizardry.log",
        "format": "json"
    },
    "cache": {
        "enabled": true,
        "ttl": 300,
        "max_size": 1000
    },
    "security": {
        "encryption_key": "${ENCRYPTION_KEY}",
        "jwt_secret": "${JWT_SECRET}"
    },
    "network": {
        "timeout": 30,
        "retries": 3,
        "user_agent": "PyWizardry/1.0.2"
    }
}

Environment Variables

# Set environment variables
export PYTHONPATH="/path/to/pywizardry"
export PYTHONWARNINGS="ignore"
export PYWIZARDRY_LOG_LEVEL="DEBUG"
export PYWIZARDRY_CACHE_SIZE="500"

📚 Examples

File Operations

# Find all Python files recursively
files = wiz.files.find("*.py", recursive=True)

# Get file metadata
metadata = wiz.files.metadata("data.csv")
print(f"Size: {metadata['size_human']}")
print(f"Created: {metadata['created']}")

# Safe file write
wiz.files.safe_write("output.txt", "Hello World!", backup=True)

# Read large file in chunks
for chunk in wiz.files.read_large_file("large.log"):
    process(chunk)

String Manipulation

# Generate secure password
password = wiz.strings.password(
    length=16,
    include_symbols=True,
    exclude_similar=True
)

# Extract information from text
text = "Contact me at john@example.com or visit https://example.com"
info = wiz.strings.extract_info(text)
# Returns: {'emails': ['john@example.com'], 'urls': ['https://example.com']}

# String similarity
similarity = wiz.strings.similarity("hello", "hallo")
# Returns: 0.8 (80% similarity)

Security Utilities

# Hash password with salt
hashed = wiz.security.hash_password("my_password")
# Returns: {'hash': '...', 'salt': '...', 'algorithm': 'pbkdf2_sha256'}

# Verify password
is_valid = wiz.security.verify_password("my_password", hashed)

# JWT tokens
token = wiz.security.jwt_encode(
    {"user_id": 123, "role": "admin"},
    "secret_key",
    expires_in=3600
)

payload = wiz.security.jwt_decode(token, "secret_key")