Skip to content
This repository was archived by the owner on Apr 7, 2020. It is now read-only.

Commit 52ad74d

Browse files
committed
fixed
1 parent 3ffd533 commit 52ad74d

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

Converter_UI.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def main():
2424
vex_save_folder = StringVar()
2525
vex_save_name = StringVar()
2626
replace = BooleanVar()
27+
progress = StringVar()
2728

2829
# Column 1
2930
status_label = Label(mainframe, text="Status: ")
@@ -46,9 +47,8 @@ def main():
4647

4748
def extract_decode():
4849
if temp_folder.get() != "":
49-
dot_vex_convert.DEFAULT_TEMP_FILE_LOCATION = temp_folder.get()
50-
dot_vex_convert.extract_dot_vex(vex_open.get(), code_folder.get(), progress_show_label)
51-
progress_show_label["text"] = "extract complete"
50+
dot_vex_convert.temp_location = temp_folder.get()
51+
dot_vex_convert.extract_dot_vex(vex_open.get(), code_folder.get(),temp_folder.get(), progress.set)
5252

5353
extract_decode_button = Button(
5454
mainframe, text="Extract and Decode", command=extract_decode)
@@ -83,13 +83,14 @@ def extract_decode():
8383

8484
def convert_to_dot_vex():
8585
if temp_folder.get != "":
86-
dot_vex_convert.DEFAULT_TEMP_FILE_LOCATION = temp_folder.get()
86+
dot_vex_convert.temp_location = temp_folder.get()
8787
dot_vex_convert.update_dot_vex(
8888
vex_open.get(),
8989
vex_save_folder.get(),
9090
vex_save_name.get(),
9191
code_folder.get(),
92-
progress_show_label["text"])
92+
temp_folder.get(),
93+
progress.set)
9394

9495
convert_vex_button = Button(mainframe, text="Convert to .vex File", command=convert_to_dot_vex)
9596
convert_vex_button.grid(column=2, row=7, sticky=(N, E))
@@ -111,7 +112,7 @@ def replace_command():
111112
text="replace old .vex file", command=replace_command, variable=replace)
112113
replace_checkbox.grid(column=2, row=8, sticky=(W, N))
113114

114-
progress_show_label = Label(mainframe, text="")
115+
progress_show_label = Label(mainframe, textvariable = progress)
115116
progress_show_label.grid(column=2, row=9, sticky=(W, N))
116117

117118
# Column 3

dot_vex_convert.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
import base64
88
import os
99

10-
DEFAULT_TEMP_FILE_LOCATION = "./temp/"
1110

1211

13-
def extract_dot_vex(vex_file_location: str, save_folder_location: str, progress):
12+
def extract_dot_vex(vex_file_location: str, save_folder_location: str,temp_location, progress):
1413
"""
1514
1615
:param vex_file_location: the .vex file location, should include the .vex file
@@ -20,24 +19,25 @@ def extract_dot_vex(vex_file_location: str, save_folder_location: str, progress)
2019

2120
progress("extracting json from .vex tar file")
2221
dot_vex_file = tarfile.open(vex_file_location)
23-
dot_vex_file.extractall(DEFAULT_TEMP_FILE_LOCATION)
22+
dot_vex_file.extractall(temp_location)
2423
dot_vex_file.close()
2524
progress("file extracted, loading json")
26-
with open(DEFAULT_TEMP_FILE_LOCATION + "___ThIsisATemPoRaRyFiLE___.json") as content:
25+
with open(temp_location + "/___ThIsisATemPoRaRyFiLE___.json") as content:
2726
dot_vex_json: dict = json.load(content)
2827
if not os.path.isdir(save_folder_location):
2928
os.mkdir(save_folder_location)
3029
progress("extracting and decode files from json")
3130
for x in dot_vex_json["files"]:
3231
with open(save_folder_location + "/" + x, "wb") as file:
3332
file.write(base64.b64decode(dot_vex_json["files"][x]))
34-
progress(len(dot_vex_json["files"]), "Files extracted from .vex")
33+
progress(str(len(dot_vex_json["files"])) + "Files extracted from .vex")
3534

3635

3736
def update_dot_vex(vex_file_location: str,
3837
save_folder_location: str,
3938
save_file_name: str,
4039
vex_decode_folder_location: str,
40+
temp_location,
4141
progress=print
4242
):
4343
"""
@@ -51,31 +51,31 @@ def update_dot_vex(vex_file_location: str,
5151

5252
progress("extracting json from .vex tar file")
5353
dot_vex_file = tarfile.open(vex_file_location)
54-
dot_vex_file.extractall(DEFAULT_TEMP_FILE_LOCATION)
54+
dot_vex_file.extractall(temp_location)
5555
dot_vex_file.close()
5656
if not os.path.isdir(save_folder_location):
5757
os.mkdir(save_folder_location)
5858
progress("loading json")
59-
with open(DEFAULT_TEMP_FILE_LOCATION + "___ThIsisATemPoRaRyFiLE___.json") as content:
59+
with open(temp_location + "/___ThIsisATemPoRaRyFiLE___.json") as content:
6060
dot_vex_json: dict = json.load(content)
6161
encode_files: list = os.listdir(vex_decode_folder_location)
6262
progress("replacing file inside json")
6363
for x in encode_files:
6464
with open(vex_decode_folder_location + x, "rb") as file:
6565
dot_vex_json["files"][x] = base64.b64encode(file.read()).decode("utf-8")
6666
progress("replace the json file")
67-
os.remove(DEFAULT_TEMP_FILE_LOCATION + "___ThIsisATemPoRaRyFiLE___.json")
68-
with open(DEFAULT_TEMP_FILE_LOCATION + "___ThIsisATemPoRaRyFiLE___.json", "w") as content:
67+
os.remove(temp_location + "/___ThIsisATemPoRaRyFiLE___.json")
68+
with open(temp_location + "/___ThIsisATemPoRaRyFiLE___.json", "w") as content:
6969
json.dump(dot_vex_json, content)
7070
try:
7171
os.remove(save_folder_location + "/" + save_file_name)
7272
except:
7373
progress("we don't need to remove the json file")
7474
dot_vex_save_file = tarfile.open(save_folder_location + "/" + save_file_name, "w")
7575
dot_vex_save_file.add(
76-
DEFAULT_TEMP_FILE_LOCATION +
77-
"___ThIsisATemPoRaRyFiLE___.json",
78-
"___ThIsisATemPoRaRyFiLE___.json")
76+
temp_location +
77+
"/___ThIsisATemPoRaRyFiLE___.json",
78+
"/___ThIsisATemPoRaRyFiLE___.json")
7979

8080
dot_vex_save_file.close()
8181
progress("replace/update .vex file complete")

0 commit comments

Comments
 (0)