{"id":37070891,"url":"https://github.com/rxchi1d/py7zz","last_synced_at":"2026-02-15T19:25:17.852Z","repository":{"id":305193759,"uuid":"1019561091","full_name":"RxChi1d/py7zz","owner":"RxChi1d","description":"Cross-platform Python wrapper for 7zz CLI object-oriented API","archived":false,"fork":false,"pushed_at":"2025-12-13T13:37:12.000Z","size":863,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-14T20:58:03.303Z","etag":null,"topics":["7zip","automation","compression","cross-platform","python-wrapper"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RxChi1d.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-07-14T14:13:39.000Z","updated_at":"2025-12-13T13:37:15.000Z","dependencies_parsed_at":"2025-08-06T17:22:45.278Z","dependency_job_id":"b623592c-ba99-4771-bd9f-63e242712634","html_url":"https://github.com/RxChi1d/py7zz","commit_stats":null,"previous_names":["rxchi1d/py7zz"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/RxChi1d/py7zz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxChi1d%2Fpy7zz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxChi1d%2Fpy7zz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxChi1d%2Fpy7zz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxChi1d%2Fpy7zz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RxChi1d","download_url":"https://codeload.github.com/RxChi1d/py7zz/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxChi1d%2Fpy7zz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["7zip","automation","compression","cross-platform","python-wrapper"],"created_at":"2026-01-14T08:16:52.839Z","updated_at":"2026-01-14T08:16:53.501Z","avatar_url":"https://github.com/RxChi1d.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nSPDX-License-Identifier: MIT\nSPDX-FileCopyrightText: 2025 py7zz contributors\n--\u003e\n\n# py7zz\n\n[![PyPI](https://img.shields.io/pypi/v/py7zz)](https://pypi.org/project/py7zz/)\n[![Python](https://img.shields.io/pypi/pyversions/py7zz)](https://pypi.org/project/py7zz/)\n[![License](https://img.shields.io/pypi/l/py7zz)](https://github.com/rxchi1d/py7zz/blob/main/LICENSE)\n[![CI](https://github.com/rxchi1d/py7zz/workflows/CI/badge.svg)](https://github.com/rxchi1d/py7zz/actions)\n\nA Python wrapper for 7zz CLI tool providing cross-platform archive operations with built-in security protection, Windows filename compatibility, and comprehensive API support.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [API Reference](#api-reference)\n- [Advanced Features](#advanced-features)\n- [Migration Guide](#migration-guide)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Cross-platform**: Windows, macOS, Linux\n- **50+ formats**: 7Z, ZIP, TAR, RAR, and more\n- **API compatible**: Drop-in replacement for `zipfile`/`tarfile`\n- **Windows compatibility**: Automatic filename sanitization\n- **Security protection**: ZIP bomb detection and file count limits\n- **Async support**: Non-blocking operations with progress\n- **Zero dependencies**: Bundled 7zz binary\n\n## Installation\n\n```bash\npip install py7zz\n```\n\nFor development:\n```bash\ngit clone https://github.com/rxchi1d/py7zz.git\ncd py7zz\npip install -e .\n```\n\n## Quick Start\n\n### Basic Usage\n\n```python\nimport py7zz\n\n# Create archive\npy7zz.create_archive('backup.7z', ['documents/', 'photos/'])\n\n# Extract archive\npy7zz.extract_archive('backup.7z', 'extracted/')\n\n# List contents\nwith py7zz.SevenZipFile('backup.7z', 'r') as sz:\n    print(sz.namelist())\n```\n\n### Drop-in Replacement\n\n```python\n# OLD: zipfile\nimport zipfile\nwith zipfile.ZipFile('archive.zip', 'r') as zf:\n    zf.extractall('output/')\n\n# NEW: py7zz (identical API)\nimport py7zz\nwith py7zz.SevenZipFile('archive.7z', 'r') as sz:\n    sz.extractall('output/')\n```\n\n### Async Operations\n\n```python\nimport asyncio\nimport py7zz\n\nasync def main():\n    await py7zz.create_archive_async('backup.7z', ['data/'])\n    await py7zz.extract_archive_async('backup.7z', 'output/')\n\nasyncio.run(main())\n```\n\n## API Reference\n\n### Core Classes\n\n#### `SevenZipFile(file, mode='r', preset=None)`\n\nMain class for archive operations, compatible with `zipfile.ZipFile`.\n\n**Parameters:**\n- `file`: Path to archive\n- `mode`: 'r' (read), 'w' (write), 'a' (append)\n- `preset`: Compression preset ('fast', 'balanced', 'ultra')\n\n**Methods:**\n- `namelist()`: List all files\n- `extractall(path, members)`: Extract files\n- `add(name, arcname)`: Add file\n- `read(name)`: Read file content\n- `testzip()`: Test integrity\n\n### Simple Functions\n\n#### `create_archive(path, files, preset='balanced')`\nCreate archive from files.\n\n#### `extract_archive(path, output_dir='.')`\nExtract all files from archive.\n\n#### `test_archive(path)`\nTest archive integrity.\n\n### Security Features\n\n#### `SecurityConfig(max_file_count=5000, max_compression_ratio=100.0, max_total_size=10737418240)`\nConfigure security limits for archive processing.\n\n#### `check_file_count_security(file_list, config=None)`\nCheck if archive file count exceeds security limits.\n\n### Filename Utilities\n\n#### `sanitize_filename(filename)`\nSanitize filename for Windows compatibility.\n\n#### `is_valid_windows_filename(filename)`\nCheck if filename is valid on Windows.\n\n#### `get_safe_filename(filename, existing_names=None)`\nGet Windows-compatible filename with conflict resolution.\n\n### Async API\n\n#### `AsyncSevenZipFile`\nAsync version of SevenZipFile with identical methods.\n\n#### `create_archive_async()`, `extract_archive_async()`\nAsync versions of simple functions.\n\n### Configuration\n\n#### Compression Presets\n- `'fast'`: Quick compression\n- `'balanced'`: Default\n- `'ultra'`: Maximum compression\n\n#### Logging\n```python\npy7zz.setup_logging('INFO')  # Configure logging\npy7zz.disable_warnings()     # Hide warnings\n```\n\n### Exception Handling\n\npy7zz provides specific exceptions for different error conditions:\n\n```python\nfrom py7zz.exceptions import (\n    ZipBombError,           # Potential ZIP bomb detected\n    SecurityError,          # Security limits exceeded\n    PasswordRequiredError,  # Archive requires password\n    FileNotFoundError,      # File or archive not found\n    CorruptedArchiveError   # Archive is corrupted\n)\n\ntry:\n    py7zz.extract_archive('archive.7z')\nexcept ZipBombError:\n    print(\"Archive may be a ZIP bomb\")\nexcept PasswordRequiredError:\n    print(\"Archive is password protected\")\nexcept CorruptedArchiveError:\n    print(\"Archive is corrupted\")\n```\n\nSee [API Documentation](docs/API.md) for complete reference.\n\n## Migration Guide\n\n### From zipfile\n\n```python\n# Change import\nimport py7zz  # was: import zipfile\n\n# Change class name\nwith py7zz.SevenZipFile('archive.7z', 'r') as sz:  # was: zipfile.ZipFile\n    sz.extractall()  # Same API!\n```\n\n### From tarfile\n\n```python\n# Change import\nimport py7zz  # was: import tarfile\n\n# Use same class\nwith py7zz.SevenZipFile('archive.tar.gz', 'r') as sz:  # was: tarfile.open\n    sz.extractall()  # Same API!\n```\n\nSee [Migration Guide](docs/MIGRATION.md) for detailed instructions.\n\n## Supported Formats\n\n| Format | Read | Write |\n|--------|------|-------|\n| 7Z | ✅ | ✅ |\n| ZIP | ✅ | ✅ |\n| TAR | ✅ | ✅ |\n| RAR | ✅ | ❌ |\n| GZIP | ✅ | ✅ |\n| BZIP2 | ✅ | ✅ |\n| XZ | ✅ | ✅ |\n\nAnd 40+ more formats for reading.\n\n## Advanced Features\n\n### Security Protection\n\nBuilt-in protection against malicious archives:\n\n```python\nfrom py7zz import SecurityConfig, ZipBombError\n\n# Configure security limits\nconfig = SecurityConfig(max_file_count=1000, max_compression_ratio=50.0)\n\ntry:\n    py7zz.extract_archive('suspicious.zip')\nexcept ZipBombError as e:\n    print(f\"Potential ZIP bomb detected: {e}\")\n```\n\n### Windows Filename Compatibility\n\nAutomatically handles Windows restrictions and provides utilities:\n\n```python\nfrom py7zz import sanitize_filename, is_valid_windows_filename\n\n# Auto-sanitization during extraction\npy7zz.extract_archive('unix-archive.tar.gz')  # Files sanitized automatically\n\n# Manual filename utilities\nsafe_name = sanitize_filename(\"invalid\u003cfile\u003ename.txt\")  # → \"invalid_file_name.txt\"\nis_valid = is_valid_windows_filename(\"CON.txt\")  # → False\n```\n\n### Progress Monitoring\n\n```python\nasync def progress_callback(info):\n    print(f\"Progress: {info.percentage:.1f}%\")\n\nawait py7zz.extract_archive_async('large.7z', progress_callback=progress_callback)\n```\n\n### Batch Operations\n\n```python\narchives = ['backup1.7z', 'backup2.7z', 'backup3.7z']\npy7zz.batch_extract_archives(archives, 'output/')\n```\n\n## Development\n\n### Setup\n\n```bash\n# Clone repository\ngit clone https://github.com/rxchi1d/py7zz.git\ncd py7zz\n\n# Install dependencies (development mode)\nuv sync --dev\nuv pip install -e .\n```\n\n### Testing\n\n```bash\n# Run tests\npytest\n\n# Check code quality\nruff check .\nmypy .\n```\n\n### Code Style\n\n- Follow PEP 8\n- Use type hints\n- Maximum line length: 88\n- Format with `ruff format`\n\n## Requirements\n\n- Python 3.8+\n- No external dependencies\n- Supported platforms:\n  - Windows x64\n  - macOS (Intel \u0026 Apple Silicon)\n  - Linux x86_64\n\n## Version Information\n\npy7zz follows [PEP 440](https://peps.python.org/pep-0440/) versioning standard:\n\n```python\nimport py7zz\nprint(py7zz.get_version())           # py7zz version (e.g., \"1.0.0\")\nprint(py7zz.get_bundled_7zz_version())  # 7zz version\n\n# Version types supported:\n# - Stable: 1.0.0\n# - Alpha: 1.0.0a1\n# - Beta: 1.0.0b1\n# - Release Candidate: 1.0.0rc1\n# - Development: 1.0.0.dev1\n```\n\n## Contributing\n\nWe welcome contributions! See [Contributing Guide](CONTRIBUTING.md) for:\n\n- Development setup\n- Code style guidelines\n- Commit conventions\n- Pull request process\n\n## Support\n\n- **Documentation**: [API Reference](docs/API.md)\n- **Issues**: [GitHub Issues](https://github.com/rxchi1d/py7zz/issues)\n- **Discussions**: [GitHub Discussions](https://github.com/rxchi1d/py7zz/discussions)\n\n## License\n\nPython source code: MIT (see LICENSE)\nBundled runtime: 7-Zip 7zz under its own licenses (LGPL v2.1 + unRAR; parts BSD).\nSee THIRD_PARTY_NOTICES.md and licenses/7zip-LICENSE.txt.\n\n## Acknowledgments\n\nBuilt on [7-Zip](https://www.7-zip.org/) by Igor Pavlov.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxchi1d%2Fpy7zz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxchi1d%2Fpy7zz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxchi1d%2Fpy7zz/lists"}