shutil.register_archive_format
Prev: shutil.move | Up: shutil | Next: shutil.register_unpack_format
Rel: shutil.chown, shutil.copy, shutil.copy2, shutil.copyfile
Ref: docs.python.org — shutil.register_archive_format
Tags: #public #python3 #stdlib #shutil
Import
import shutil
from shutil import register_archive_format
Signature & Overview
shutil.register_archive_format(name, function, extra_args=None, description='')
Registers an archive format.
Usage
import shutil
def dummy_pack(base_name, base_dir, **kwargs):
return f"{base_name}.custom"
shutil.register_archive_format("custom_demo", dummy_pack, description="Demo format")
try:
assert "custom_demo" in dict(shutil.get_archive_formats())
finally:
shutil.unregister_archive_format("custom_demo")
Gotchas
- Process-global registry: Custom formats registered here are visible to every
make_archive()call in the process—clean up withunregister_archive_format()in tests.
REPL Inspect
from shutil import register_archive_format
help(register_archive_format)
Linked from
Related notes
- tuts/python3/stdlib_module/shutil/move Linked here; links to this page; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/register_unpack_format 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