๐ stewbeet.plugins.compute_sha1
๐ Source Code: stewbeet/plugins/compute_sha1/__init__.py ๐
๐ Overview
The compute_sha1 plugin generates SHA1 hashes for all generated zip archives.
It scans the output directory for zip files, computes their SHA1 checksums for integrity
verification, and creates a comprehensive JSON file containing all hash values
for distribution verification, security auditing, and change detection purposes.
Feature Showcase
Example content of sha1_hashes.json

๐ฏ Purpose
- ๐ Computes SHA1 hashes for all generated zip archives
- ๐ Creates comprehensive hash manifest for integrity verification
- ๐ Enables change detection between builds
- ๐ก๏ธ Provides security checksums for distribution verification
- ๐ Scans output directory automatically for zip files
- ๐พ Generates machine-readable JSON hash file
๐ Dependencies
- ๐ Position: Should run after all archive generation plugins
- ๐ง Optional: Multiple zip files in output directory (processes all found)
- ๐ Related: Complements archive and merge_smithed_weld plugins
โ๏ธ Configuration
๐ฏ Basic Example Configuration
# No direct configuration required - uses project settings # Requires output to be configured in beet.yml: output: "build" pipeline: - ... - stewbeet.plugins.compute_sha1
๐ Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
output | string | Required | Directory containing zip files to hash |
| Hash Algorithm | constant | SHA1 | Uses SHA1 algorithm for checksum generation |
| Output File | constant | sha1_hashes.json | Filename for the generated hash manifest |
| File Filter | automatic | *.zip | Only processes files with .zip extension |
โจ Features
๐ Automatic Archive Discovery
Scans output directory for zip files to process:
- ๐ Automatically discovers all zip files in the output directory
- ๐ Uses file extension filtering to identify archive files
- ๐ Processes all found archives without manual configuration
- โ Handles empty directories gracefully with no errors
๐ SHA1 Hash Computation
Generates secure SHA1 checksums for each archive:
- ๐ Uses Python's built-in hashlib for reliable hash generation
- ๐ Reads files in binary mode for accurate checksum calculation
- ๐ฏ Generates standard hexadecimal hash representation
- โก Processes files efficiently with stream reading
๐ Hash Manifest Creation
Creates comprehensive JSON file with all computed hashes:
- ๐ Stores filename-to-hash mappings in JSON format
- ๐จ Uses json_dump for properly formatted output
- ๐พ Creates sha1_hashes.json file in the output directory
- ๐ Provides machine-readable format for automated verification
๐ก๏ธ Integrity Verification System
Enables integrity checking and change detection:
- โ Provides checksums for verifying archive integrity
- ๐ Enables detection of file corruption or tampering
- ๐ Supports automated verification workflows
- ๐ Creates audit trail for security compliance
๐ Output Directory Integration
Seamlessly integrates with beet's output directory system:
- ๐ Uses configured output directory from project settings
- โ Validates output directory existence before processing
- ๐ฏ Works with any output directory configuration
- ๐ง Integrates with beet's standard directory management
โก Efficient Processing Pipeline
Optimized for performance with minimal resource usage:
- โฑ๏ธ Uses measure_time decorator for performance monitoring
- ๐พ Reads files once for hash calculation
- ๐ Processes all files in a single pass
- ๐งน Clean and simple implementation with minimal overhead