-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
140 lines (101 loc) · 4.54 KB
/
main.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import os
import sys
# Это костыль, без него не работает сборка в екзешник
from sqlalchemy.dialects.mysql.mariadb import *
from PyQt6.QtWidgets import QFileDialog, QApplication, QMainWindow
from icecream import ic
from source.quick_open import QuickOpen
# from source.quick_open_bak import QuickOpen
from source.ui.main_ui_init import MainWindow
from source.ui.custom_ui import PrintTo
from source.ui import localize, custom_ui
from source.reaper import after_dot
from source.reapers import *
from source.delete import DeleteThread
ic.enable() if os.path.exists('dev_tools') else ic.disable()
class UnpackerMain(MainWindow, QuickOpen):
def __init__(self):
super().__init__()
sys.stdout = PrintTo(text_written=self.append_text)
self.func_name = ''
self.script_name = ''
self.file_list = []
def q_open(self):
self.file_list = list(self.file_open())
self.last_run = self.find_reaper
self.find_reaper()
def file_open(self, ext_list='', select_folder=False, more_one=False):
if not select_folder:
try:
f = ext_list.replace('|', ';;').replace('None', '')
except AttributeError:
f = ''
file_names = QFileDialog.getOpenFileNames(self, caption=localize.open_file, filter=f,
directory=self.setting['Main']['last_dir'])[0]
if more_one and file_names:
file_names = [file_names[0], '']
else:
file_names = [QFileDialog.getExistingDirectory(self, caption=localize.select_folder,
directory=self.setting['Main']['last_dir']), '']
if file_names:
self.set_setting('Main', 'last_dir', os.path.dirname(file_names[0]))
ic(file_names)
for file_name in file_names:
if file_name:
yield file_name
def file_reaper(self, index, select_folder=False, more_one=False):
try:
item = self.model.itemFromIndex(index)
data_string = self.mainList.loc[self.mainList['game_name'] == item.text()]
self.func_name = data_string['func_name'].values[0]
script_name = data_string['script_name'].values[0]
after_dot['Default'] = (data_string['ext_list'].values[0]
if data_string['ext_list'].values[0] != 'nan' else '')
ext_list = after_dot[self.func_name] if self.func_name in after_dot.keys() else after_dot['Default']
if (self.func_name in ('_Unity', '_Frostbite2', '_Frostbite3', '_CelTop') or
self.checkBox_Reimport.isChecked()):
select_folder = True
self.create_queue(ext_list, select_folder, more_one, self.func_name, script_name)
except IndexError:
pass
def create_queue(self, ext_list='', select_folder=False, more_one=False, func_name='', script_name=''):
self.func_name = func_name
self.script_name = script_name
if type(ext_list) is float:
ext_list = ''
ext_list = f'{ext_list}{localize.all_files}(*.*)'
ic(ext_list)
self.file_list = list(self.file_open(ext_list, select_folder, more_one))
self.last_run = self.find_reaper
for _ in self.file_list:
self.find_reaper()
def find_zip_method(self):
file_n = ''.join(self.file_open(more_one=True))
if file_n:
self.proc = zip_scan.ZipScanner()
self.q_connect(self.proc, file_n, header=f'{localize.file}: {file_n}...')
def empty_out(self):
if os.listdir(self.out_dir):
self.q_connect(DeleteThread(), header=f'{localize.deleting}...')
else:
print(localize.empty_folder)
class QuickUnpack(QMainWindow, QuickOpen):
def __init__(self):
super().__init__()
self.is_stop = False
self.pb = custom_ui.ProgressBar()
self.last_run = None
self.file_list = [sys.argv[1], ]
self.func_name = None
self.find_reaper()
if __name__ == "__main__":
try:
print(sys.argv[1])
app = QApplication(sys.argv)
win = QuickUnpack()
except IndexError:
app = QApplication(sys.argv)
win = UnpackerMain()
win.show()
win.raise_()
sys.exit(app.exec())