Skip to content

Commit

Permalink
[Zip] Added unzip
Browse files Browse the repository at this point in the history
  • Loading branch information
YanSte committed Aug 30, 2023
1 parent e868c9f commit 9eacc84
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/skit/zip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import subprocess

def unzip_specific_files(zip_file_path, destination_directory, specific_files=None):
"""
Unzips specific files or folders from a ZIP archive.
Parameters:
- zip_file_path (str): Path to the ZIP file to unzip.
- destination_directory (str): Directory where the files will be extracted.
- specific_files (list, optional): List of specific files or folders to extract.
Example usage:
```python
zip_file_path = "/path/to/archive.zip"
destination_directory = "/path/to/destination/"
specific_files = ["file1", "file2", "folder1/"]
unzip_specific_files(zip_file_path, destination_directory, specific_files)
```
"""
# Construire la commande unzip
unzip_command = ["unzip", zip_file_path, "-d", destination_directory]

# Ajouter des fichiers ou dossiers spécifiques à la commande, si fournis
if specific_files:
unzip_command.insert(2, *specific_files)

# Exécuter la commande unzip
subprocess.run(unzip_command)

0 comments on commit 9eacc84

Please sign in to comment.