-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '173-not-to-fail-at-missing-labeling-files' into 'develop'
173 Not to fail at missing labeling files Closes #173 See merge request epm-emrd/model_garden!214
- Loading branch information
Showing
4 changed files
with
79 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from io import BytesIO | ||
from zipfile import ZipFile | ||
|
||
|
||
class ZipFileContentFactory: | ||
|
||
@staticmethod | ||
def get_zip_file_content(*files): | ||
file = BytesIO() | ||
zip_file = ZipFile(file=file, mode='w') | ||
for file_path, file_content in files: | ||
zip_file.writestr(file_path, file_content) | ||
|
||
zip_file.close() | ||
return file.getvalue() | ||
|
||
@staticmethod | ||
def get_empty_zip_file_content(zip_file_obj, folder_subpathes): | ||
with ZipFile(zip_file_obj, 'w') as zipFile: | ||
for folder in folder_subpathes: | ||
folder_with_slash = folder + "/" if folder[-1] != '/' else folder | ||
zipFile.writestr(folder_with_slash, "") | ||
zip_file_obj.seek(0) | ||
file_content = zip_file_obj.read() | ||
zipFile.close() | ||
|
||
return file_content |