shutil.register_unpack_format
Prev: shutil.register_archive_format | Up: shutil | Next: shutil.rmtree
Rel: shutil.chown, shutil.copy, shutil.copy2, shutil.copyfile
Ref: docs.python.org — shutil.register_unpack_format
Tags: #public #python3 #stdlib #shutil
Import
import shutil
from shutil import register_unpack_format
Signature & Overview
shutil.register_unpack_format(name, extensions, function, extra_args=None, description='')
Registers an unpack format.
Usage
import shutil
def dummy_unpack(filename, extract_dir, **kwargs):
pass
shutil.register_unpack_format("custom_demo", [".cdemo"], dummy_unpack)
try:
names = [n for n, _, _ in shutil.get_unpack_formats()]
assert "custom_demo" in names
finally:
shutil.unregister_unpack_format("custom_demo")
Gotchas
- Extensions must be unique: Registering an extension already claimed by another format (like
".zip") raisesRegistryError.
REPL Inspect
from shutil import register_unpack_format
help(register_unpack_format)
Linked from
Related notes
- tuts/python3/stdlib_module/shutil/register_archive_format Linked here; links to this page; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/rmtree Linked here; links to this page; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/shutil/chown Linked here; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copy Linked here; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copy2 Linked here; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copyfile Linked here; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copyfileobj shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copymode shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copystat shared tags: #shutil, #stdlib