-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_zip.py
29 lines (23 loc) · 1.08 KB
/
create_zip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from zipfile import *
from static.svg import _create_crossword_svg
from crossword import _create_definitions_file
import os
def _create_zip(words_with_def,placements,used, crossword_matrix, edges, word_placement):
#create svg file
_create_crossword_svg(crossword_matrix, edges, word_placement, 50)
#create definitions file
_create_definitions_file(words_with_def,placements,used,word_placement)
# create a ZipFile object
root = os.path.realpath(__file__)[:-13] + 'static'
path_to_file = root + '\crossword.zip' #on whichever machine the path will end with Crossword\create_zip.py, cut final part to save file where needed
zipObj = ZipFile(path_to_file, 'w')
# Add multiple files to the zip
zipObj.write(root + '\crossword.svg', 'crossword.svg')
zipObj.write(root + '\definitions.txt', 'definitions.txt')
# close the Zip File
zipObj.close()
#clean not needed files
if os.path.exists(root + '\crossword.svg'):
os.remove(root + '\crossword.svg')
if os.path.exists(root + '\definitions.txt'):
os.remove(root + '\definitions.txt')