ZipArchives are a powerful tool for collecting files and managing data
# first we import the ZipModels module.
from pyMez.Code.DataHandlers.ZipModels import *
# a new zip archive
new_zip=ZipArchive()
# it has a default name
new_zip.path
# we can add a file to the zip archive
file_to_add=r"./Zip_Example_Files/WR15_isolation.s2p"
# just provide the path to the file to add
new_zip.add_file(file_to_add)
# now the files are listed in the attribute files
new_zip.files
# we can add files of any type
new_zip.add_file(r"./Zip_Example_Files/WR15_Compare_Corrected_Loads.png")
new_zip.files
# we can add all the files in a directory
new_zip.add_all_from_directory(r".\Zip_Example_Files\Mulitple_Files")
new_zip.files
# we can create a string and add it as a new file
new_zip.write_string(data_string="A new fake file",archive_file_name="string.txt")
# lets save the archive
new_zip.save(os.path.join(os.getcwd(),r"Zip_Example_Files\ZipArchive_Test_01.zip"))
new_zip.files
# now we can extract all of the files to a directory
new_zip.extract_all(destination_directory=r"Zip_Example_Files\Extracted_Files")
# now we close it and it goes away. Note, because of the way zip files work a copy will be saved under the default name.
# To change the default name set the options directory, specfic_descriptor, general_descriptor