A comprehensive collection of Python automation tools
Project description
Swiss Knife
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
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
# 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
skcommand: Theskname may conflict with other tools (e.g. Sketch on macOS). See the Installation Guide for details.
Command Line Usage
# 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
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
secretsmodule 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swiss_knife_py-0.2.0.tar.gz.
File metadata
- Download URL: swiss_knife_py-0.2.0.tar.gz
- Upload date:
- Size: 29.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53aedce6a9becda418debc74ac0ee36149c7cb5fd9b26bf865abde91e700c902
|
|
| MD5 |
308c655f13ea946049fe0c2d3ce28073
|
|
| BLAKE2b-256 |
9f40daee8594782eaba959cd62f8b7ffdf4d7d29949975e90bc3c6c2bcd4fd51
|
Provenance
The following attestation bundles were made for swiss_knife_py-0.2.0.tar.gz:
Publisher:
release.yml on ayoub3bidi/swiss-knife
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swiss_knife_py-0.2.0.tar.gz -
Subject digest:
53aedce6a9becda418debc74ac0ee36149c7cb5fd9b26bf865abde91e700c902 - Sigstore transparency entry: 2145141355
- Sigstore integration time:
-
Permalink:
ayoub3bidi/swiss-knife@540ee8528d4d8e8b5d7ce4b401c10801a4772b68 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ayoub3bidi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@540ee8528d4d8e8b5d7ce4b401c10801a4772b68 -
Trigger Event:
push
-
Statement type:
File details
Details for the file swiss_knife_py-0.2.0-py3-none-any.whl.
File metadata
- Download URL: swiss_knife_py-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a52e3f99bd2bc5c9b7e44461a02c29f4fd1ad2dffa79e9645a4906faa7199d0
|
|
| MD5 |
191b4e735bbcc8d8f25c83272167d97d
|
|
| BLAKE2b-256 |
2975044a0c5f1b1d62c4d7b79dfdec366df16229f3a08aeacaf3ad6b5ef7f0da
|
Provenance
The following attestation bundles were made for swiss_knife_py-0.2.0-py3-none-any.whl:
Publisher:
release.yml on ayoub3bidi/swiss-knife
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swiss_knife_py-0.2.0-py3-none-any.whl -
Subject digest:
2a52e3f99bd2bc5c9b7e44461a02c29f4fd1ad2dffa79e9645a4906faa7199d0 - Sigstore transparency entry: 2145142178
- Sigstore integration time:
-
Permalink:
ayoub3bidi/swiss-knife@540ee8528d4d8e8b5d7ce4b401c10801a4772b68 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ayoub3bidi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@540ee8528d4d8e8b5d7ce4b401c10801a4772b68 -
Trigger Event:
push
-
Statement type: