ddi-fw 0.0.24__py3-none-any.whl → 0.0.26__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,8 +40,8 @@ class ZipHelper:
40
40
  def zip_as_multipart(self, zip_name, file_path, output_path, chunk_size):
41
41
  parent_folder = os.path.dirname(file_path)
42
42
 
43
- parts_path = f"{parent_folder}/parts"
44
- create_folder_if_not_exists(parts_path)
43
+ # parts_path = f"{parent_folder}/parts"
44
+ # create_folder_if_not_exists(parts_path)
45
45
  # file_name, file_extension = os.path.splitext(file_path)
46
46
  # file_name = os.path.basename(file_path)
47
47
  file_name, folder = get_file_name_and_folder(file_path)
@@ -52,15 +52,17 @@ class ZipHelper:
52
52
  self.zip_single_file(zip_name, file_path, output_path)
53
53
  else:
54
54
  return
55
- with open(file_path, 'rb') as f:
55
+ with open(output_path+'/'+zip_name+'.zip', 'rb') as f:
56
56
  chunk_number = 1
57
57
  while True:
58
58
  chunk = f.read(chunk_size)
59
59
  if not chunk:
60
60
  break
61
- with open(f"{parts_path}/{file_name}.part{chunk_number:03}", 'wb') as chunk_file:
61
+ with open(f"{output_path}/{zip_name}.zip.part{chunk_number:03}", 'wb') as chunk_file:
62
62
  chunk_file.write(chunk)
63
63
  chunk_number += 1
64
+ if os.path.exists(output_path+'/'+zip_name+'.zip'):
65
+ os.remove(output_path+'/'+zip_name+'.zip')
64
66
 
65
67
  def zip(self, zip_prefix, input_path, output_path, chunk_size):
66
68
  files_paths = [input_path+'/' + p for p in os.listdir(input_path)]
@@ -87,6 +89,13 @@ class ZipHelper:
87
89
  for file_path in value:
88
90
  zipObj.write(file_path, basename(file_path))
89
91
 
92
+ def extract_single_file(self, file_path, output_path):
93
+ with z.ZipFile(file_path, 'r') as z1:
94
+ z1.extractall(path=output_path)
95
+
96
+ '''
97
+ Extract zip files from the given path to the output path
98
+ '''
90
99
  def extract(self, input_path, output_path):
91
100
  files_paths = [input_path+'/' + p for p in os.listdir(input_path)]
92
101
  if not os.path.exists(output_path):
@@ -97,13 +106,13 @@ class ZipHelper:
97
106
  z1.extractall(path=output_path)
98
107
  print(f'{file_path} has been extracted')
99
108
 
100
- def extract_multiparts(self, output_path, parts_path, output_file):
101
- input_parts = [parts_path+'/' + p for p in os.listdir(parts_path)]
109
+ def extract_multiparts(self, input_path, output_path, output_file):
110
+ parts = [input_path+'/' + p for p in os.listdir(input_path)]
102
111
  with open(f"{output_path}/{output_file}", 'wb') as outfile:
103
- for part in input_parts:
112
+ for part in parts:
104
113
  with open(part, 'rb') as infile:
105
114
  outfile.write(infile.read())
106
- self.extract(parts_path, output_path)
115
+ self.extract_single_file(f"{output_path}/{output_file}", output_path)
107
116
 
108
117
 
109
118
  # if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ddi_fw
3
- Version: 0.0.24
3
+ Version: 0.0.26
4
4
  Summary: Do not use :)
5
5
  Author-email: Kıvanç Bayraktar <bayraktarkivanc@gmail.com>
6
6
  Maintainer-email: Kıvanç Bayraktar <bayraktarkivanc@gmail.com>
@@ -78,8 +78,8 @@ ddi_fw/test/type_guarding_test.py,sha256=KxjyBxohDu7lwpejalCj-REjtJ-k1S1wQbOB6TG
78
78
  ddi_fw/utils/__init__.py,sha256=nhNU_sEp55xsZ5VtvhozjKg6r4GWP6SJI13v8F_jbCg,217
79
79
  ddi_fw/utils/enums.py,sha256=19eJ3fX5eRK_xPvkYcukmug144jXPH4X9zQqtsFBj5A,671
80
80
  ddi_fw/utils/utils.py,sha256=Na6Y8mY-CFbQjrgd9xC8agcrjVvTj_7KIXqFm1H_3qU,3549
81
- ddi_fw/utils/zip_helper.py,sha256=oOnXlMVaH1Bj5EZpcOIxQMfKnLcuwamQCEOIuN288HQ,4976
82
- ddi_fw-0.0.24.dist-info/METADATA,sha256=eKPBSBXAX-ooVfz_FTeKNPsV7aU3byQ7IDS_FVAOK78,1541
83
- ddi_fw-0.0.24.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
84
- ddi_fw-0.0.24.dist-info/top_level.txt,sha256=PMwHICFZTZtcpzQNPV4UQnfNXYIeLR_Ste-Wfc1h810,7
85
- ddi_fw-0.0.24.dist-info/RECORD,,
81
+ ddi_fw/utils/zip_helper.py,sha256=tnzA5SwiIbXxNygR9WGQmT7wQ9BEssJHNziQDHlavTM,5378
82
+ ddi_fw-0.0.26.dist-info/METADATA,sha256=Q6MCymz9sAM4SVPw0miBH8gVhq4W9ZmkF5NV9s9e8Rc,1541
83
+ ddi_fw-0.0.26.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
84
+ ddi_fw-0.0.26.dist-info/top_level.txt,sha256=PMwHICFZTZtcpzQNPV4UQnfNXYIeLR_Ste-Wfc1h810,7
85
+ ddi_fw-0.0.26.dist-info/RECORD,,