Python | shutil.unregister_archive_format() method

Shutil module in Python provides many functions of high-level operations on files and collections of files. It comes under Python’s standard utility modules. This module helps in automating the process of copying and removal of files and directories.

shutil.unregister_archive_format() method in Python is used to unregister or remove an archive format from the list of available supported archive formats.

We can also register a new format or specify own function for archiving existing formats using shutil.register_archive_format() method or get the list of all supported available archive format using shutil.get_archive_formats() method.



Syntax: shutil.unregister_archive_format(name)

Parameter:
name: A string representing the name of the archive format which is to be removed from the list.

Return Type: This method does not return any value.

Code: Use of shutil.unregister_archive_format() method

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to explain shutil.unregister_archive_format() method  
    
# importing shutil module 
import shutil
  
# Get the list of 
# supported archive formats
formats = shutil.get_archive_formats()
  
# Print the list
print("Supported archive formats:")
print(formats, "\n")
  
# Remove an archive format
name = "bztar"
shutil.unregister_archive_format(name)
print("'% s' archive format unregistered successfully." % name, "\n")
  
# Get the list of 
# supported archive formats
formats = shutil.get_archive_formats()
  
# Print the list
print("Supported archive formats:")
print(formats, "\n")

chevron_right


Output:

Supported archive formats:
[(‘bztar’, [‘.tar.bz2’, ‘.tbz2’], “bzip2’ed tar-file”), (‘gztar’, [‘.tar.gz’, ‘.tgz’], “gzip’ed tar-file”), (‘tar’, [‘.tar’], ‘uncompressed tar file’), (‘xztar’, [‘.tar.xz’, ‘.txz’], “xz’ed tar-file”), (‘zip’, [‘.zip’], ‘ZIP file’)]

‘bztar’ archive format unregistered successfully.

Supported archive formats:
[(‘gztar’, “gzip’ed tar-file”), (‘tar’, ‘uncompressed tar file’), (‘xztar’, “xz’ed tar-file”), (‘zip’, ‘ZIP file’)]

Reference: https://docs.python.org/3/library/shutil.html



My Personal Notes arrow_drop_up

self motivated and passionate programmer

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.