Metadata-Version: 2.4
Name: swiss-knife-py
Version: 0.2.0
Summary: A comprehensive collection of Python automation tools
Author-email: Ayoub Abidi <contact@ayoub3bidi.me>
Maintainer-email: Ayoub Abidi <contact@ayoub3bidi.me>
License: MIT
Project-URL: Homepage, https://github.com/ayoub3bidi/swiss-knife
Project-URL: Repository, https://github.com/ayoub3bidi/swiss-knife.git
Project-URL: Issues, https://github.com/ayoub3bidi/swiss-knife/issues
Project-URL: Documentation, https://github.com/ayoub3bidi/swiss-knife/docs
Keywords: automation,cli,tools,utilities,file-management
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
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 :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: xml
Requires-Dist: defusedxml>=0.7.0; extra == "xml"
Provides-Extra: all
Requires-Dist: defusedxml>=0.7.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=6.0.0; extra == "dev"
Requires-Dist: pytest-cov>=2.10.0; extra == "dev"
Requires-Dist: ruff>=0.4.0; extra == "dev"
Requires-Dist: mypy<1.6.0,>=0.910; extra == "dev"
Requires-Dist: bandit[toml]>=1.7.0; extra == "dev"
Dynamic: license-file

# Swiss Knife

<p align="center">
    <img src="https://raw.githubusercontent.com/ayoub3bidi/swiss-knife/main/logo.png" alt="Swiss Knife Logo" width="100"/> <br/>
    A Python package that provides essential automation tools with a focus on safety, security, and ease of use.
</p>

<p align="center">
    <a href="https://pypi.org/project/swiss-knife-py/"><img src="https://img.shields.io/pypi/pyversions/swiss-knife-py.svg" alt="Python versions"></a>
    <a href="https://github.com/ayoub3bidi/swiss-knife/actions/workflows/ci.yml"><img src="https://github.com/ayoub3bidi/swiss-knife/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
    <a href="https://github.com/ayoub3bidi/swiss-knife/actions/workflows/security.yml"><img src="https://github.com/ayoub3bidi/swiss-knife/actions/workflows/security.yml/badge.svg" alt="Security"></a>
    <a href="https://codecov.io/gh/ayoub3bidi/swiss-knife"><img src="https://codecov.io/gh/ayoub3bidi/swiss-knife/branch/main/graph/badge.svg" alt="codecov"></a>
    <a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff"></a>
</p>

## Features

### File Management
- **Duplicate Detection**: Find and remove duplicate files using cryptographic hashes (MD5, SHA1, SHA256, SHA512)
- **Bulk Renaming**: Rename files in bulk using regex patterns with safety checks and dry-run mode

### Text Processing  
- **CSV Conversion**: Convert CSV files to JSON/XML with intelligent type inference and validation

### Security & Automation
- **Password Generation**: Generate secure passwords with customizable policies and strength analysis

### Utilities
- **Data Helpers**: Parse booleans and environment variables, convert key styles, validate UUIDs and HTTP status codes, and decode base64 text

## Standalone Scripts

The `scripts/` directory contains standalone scripts that are **not** part of the installable package. They are not installed by `pip install swiss-knife-py` and may have their own `requirements.txt` files with heavier dependencies (e.g. Pillow, pydub, psutil, qrcode). These scripts predate the packaged modules, have **not been audited for divergence**, and overlap with functionality now provided by `swiss_knife.*`. Use the installable package for the supported API and CLI tools listed above.

| Directory | Contents |
|---|---|
| `scripts/automation/` | Standalone automation scripts |
| `scripts/convert/` | File format conversion utilities |
| `scripts/development_tools/` | Developer workflow helpers |
| `scripts/file_management/` | File operations (predates the packaged `file_management` module) |
| `scripts/network_web/` | Networking and web utilities |
| `scripts/system_utilities/` | System administration scripts |
| `scripts/text_processing/` | Text transformation scripts (predates the packaged `text_processing` module) |
| `scripts/utilities/` | General-purpose helpers (predates the packaged `utilities` module) |

Each subdirectory has its own README. These scripts are retained for reference and standalone use; the packaged modules under `swiss_knife/` are the maintained, tested, and recommended APIs.

## Quick Start

### Installation

```bash
# Basic installation
pip install swiss-knife-py

# With XML processing support (recommended for security)
pip install swiss-knife-py[xml]

# With development tools
pip install swiss-knife-py[dev]
```

> **Note on the `sk` command:** The `sk` name may conflict with other tools (e.g. Sketch on macOS). See the [Installation Guide](docs/installation.md#basic-installation) for details.

### Command Line Usage

```bash
# Find duplicate files
sk-duplicates ~/Documents --algorithm sha256 --min-size 1048576

# Convert CSV to JSON
sk-csv data.csv --format json --output data.json --pretty

# Generate secure password
sk-password --length 16 --exclude-ambiguous

# Bulk rename files
sk-rename 'IMG_(\d+)' 'photo_\1' ~/Pictures --dry-run
```

### Python API Usage

```python
from swiss_knife.file_management.duplicate_finder import find_duplicates
from swiss_knife.file_management.bulk_renamer import bulk_rename
from swiss_knife.text_processing.csv_converter import convert_csv
from swiss_knife.automation.password_generator import generate_password
from swiss_knife.utilities import get_env_int, convert_keys_to_camel_case

# Find duplicates
duplicates = find_duplicates(["/path/to/search"], algorithm="sha256")
print(f"Found {len(duplicates)} duplicate groups")

# Convert CSV to JSON
convert_csv("data.csv", "json", output_path="data.json", pretty=True)

# Generate secure password
password = generate_password(length=16, include_symbols=True)
print(f"Generated password: {password}")

# Bulk rename with safety checks
renamed_count = bulk_rename(r"IMG_(\d+)", r"photo_\1", "/path/to/images", dry_run=True)

# Parse helpers
retry_count = get_env_int("RETRY_COUNT", default=3)
payload = convert_keys_to_camel_case({"first_name": "Alice"})
```

## Security Features

Swiss Knife prioritizes security with multiple safety mechanisms:

- **Safe Defaults**: All destructive operations require explicit confirmation
- **Input Validation**: Comprehensive validation prevents injection attacks
- **Path Safety**: Protection against path traversal vulnerabilities  
- **Memory Limits**: Configurable limits prevent memory exhaustion
- **Dry Run Mode**: Test operations before executing them
- **Cryptographic Security**: Uses `secrets` module for secure randomness

## Development

```bash
# Clone the repository
git clone https://github.com/ayoub3bidi/swiss-knife.git
cd swiss-knife

# Install in development mode
pip install -e .[dev,all]

# Run tests
pytest

# Run linting
ruff check swiss_knife/

# Run security checks
bandit -r swiss_knife/
```
