zyyaratorazov commited on
Commit
51f8904
·
verified ·
1 Parent(s): 28651cc

Delete unzip_script.py

Browse files
Files changed (1) hide show
  1. unzip_script.py +0 -44
unzip_script.py DELETED
@@ -1,44 +0,0 @@
1
- import zipfile
2
- import os
3
- import sys
4
-
5
- def extract_zip(zip_path, extract_to_path):
6
- """
7
- Belirtilen zip dosyasını belirtilen dizine çıkarır.
8
- """
9
- if not os.path.exists(zip_path):
10
- print(f"Hata: {zip_path} bulunamadı.")
11
- sys.exit(1)
12
-
13
- try:
14
- with zipfile.ZipFile(zip_path, 'r') as zip_ref:
15
- zip_ref.extractall(extract_to_path)
16
- print(f"'{zip_path}' başarıyla '{extract_to_path}' konumuna çıkarıldı.")
17
- except zipfile.BadZipFile:
18
- print(f"Hata: '{zip_path}' geçerli bir zip dosyası değil.")
19
- sys.exit(1)
20
- except Exception as e:
21
- print(f"Zip dosyası çıkarılırken bir hata oluştu: {e}")
22
- sys.exit(1)
23
-
24
- if __name__ == "__main__":
25
- # Varsayılan değerler
26
- default_zip_file = "directory_data.zip"
27
- default_extract_dir = "/app/extracted_data"
28
-
29
- # Komut satırı argümanları al
30
- # python unzip_script.py <zip_dosyası_yolu> <çıkarılacak_dizin_yolu>
31
- if len(sys.argv) > 2:
32
- zip_file = sys.argv[1]
33
- extract_dir = sys.argv[2]
34
- elif len(sys.argv) == 2:
35
- zip_file = sys.argv[1]
36
- extract_dir = default_extract_dir
37
- else:
38
- zip_file = default_zip_file
39
- extract_dir = default_extract_dir
40
-
41
- # Çıkarılacak dizin yoksa oluştur
42
- os.makedirs(extract_dir, exist_ok=True)
43
-
44
- extract_zip(zip_file, extract_dir)