UuuNyaa / x7zipfile

x7zipfile is a thin 7-zip command wrapper for Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

x7zipfile

x7zipfile is a thin 7-zip extract command wrapper for Python.

Features

  • The interface follows the style of zipfile.
  • Archive operations are handled by executing external tool: 7z.
  • Works with single file.
  • Supports extract and list operations.
  • Not supports compress operations.
  • Supports archive formats that can be processed by the 7z command.
  • Supports Unicode filenames.
  • Supports password-protected archives.

Installation

Requirements

  • Python 3.7 or later
  • 7-zip 16 or later

Download

Install

  1. Place the x7zipfile.py file where you want.
  2. Install 7-zip.

Usage

Simple extract example

import x7zipfile

with x7zipfile.x7ZipFile('myarchive.7z') as zipfile:
    for info in zipfile.infolist():
        print(info.filename, info.file_size)
        if info.filename == 'README':
            zipfile.extract(info)

Dynamic module load example

import importlib

namespace = 'x7zipfile'
loader = importlib.machinery.SourceFileLoader(namespace, '/path/to/x7zipfile.py')
x7zipfile = loader.load_module(namespace)

References

About

x7zipfile is a thin 7-zip command wrapper for Python.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 100.0%