Skip to main content

A comprehensive collection of Python automation tools

Project description

Swiss Knife

Swiss Knife Logo
A Python automation toolkit for file management, text processing, and security utilities.

Swiss Knife is a Python package that provides essential automation tools with a focus on safety, security, and ease of use.

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

Standalone Scripts

This repository also contains standalone scripts in automation/, convert/, file_management/, network_web/, system_utilities/, text_processing/, utilities/, and development_tools/. These scripts are not installed by pip install swiss-knife-py; use the separate requirements files in those directories when running them directly from the repository.

Quick Start

Installation

# 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]

Command Line Usage

# Find duplicate files
sk-duplicates ~/Documents --algorithm sha256 --min-size 1MB

# 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

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

# 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)

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

# 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/

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

swiss_knife_py-0.1.2.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

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

swiss_knife_py-0.1.2-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file swiss_knife_py-0.1.2.tar.gz.

File metadata

  • Download URL: swiss_knife_py-0.1.2.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for swiss_knife_py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2eb72daffb51423b4c77f56a16cdec522f61c1e6d3ef9e532f2d700d9ff2cd5e
MD5 13113de93a5a83d5de36454acc88e806
BLAKE2b-256 eb8f97cd8be3fcdaf34a97e05681144615ea012eee5f7268a75dc341ac099c04

See more details on using hashes here.

Provenance

The following attestation bundles were made for swiss_knife_py-0.1.2.tar.gz:

Publisher: release.yml on ayoub3bidi/swiss-knife

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swiss_knife_py-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: swiss_knife_py-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for swiss_knife_py-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22a59d05874ef82e336319a4b3c2aa999fedc686b47275cd531eafc7887c3a78
MD5 b5d159e51a7ad634919e305c86032b2a
BLAKE2b-256 279afc092249e0deb2489b6a7be05fccd28115ccb44d444e7e500b2e7085f526

See more details on using hashes here.

Provenance

The following attestation bundles were made for swiss_knife_py-0.1.2-py3-none-any.whl:

Publisher: release.yml on ayoub3bidi/swiss-knife

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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