@@ -194,16 +194,20 @@ def decompile(list_of_files, source=None, platform=None):
194
194
logging .debug ("formatstring is %s , base is %s, V8Reader is %s, temp \
195
195
is %s" % (formatstring , base , V8Reader , tempbat ))
196
196
197
-
198
197
with open (tempbat , 'w' , encoding = 'cp866' ) as temp :
199
198
temp .write ('@echo off\n ' )
200
- temp .write (format ('"%s" %s /DisableStartupMessages %s %s' % (pathbin1c , base , V8Reader , formatstring )))
199
+ temp .write (format ('"%s" %s /DisableStartupMessages %s %s' % (pathbin1c ,
200
+ base , V8Reader , formatstring ))
201
+ )
201
202
temp .close ()
202
203
result = subprocess .check_call (['cmd.exe' , '/C' , tempbat ])
204
+ assert result == 0 , format ("Не удалось разобрать\
205
+ обработку %s" % (fullpathfile ))
203
206
if not result == 0 :
204
207
logging .error (format ("Не удалось разобрать \
205
208
обработку %s" % (fullpathfile )))
206
- raise format ("Не удалось разобрать обработку %s" % (fullpathfile ))
209
+ raise format ("Не удалось разобрать\
210
+ обработку %s" % (fullpathfile ))
207
211
returnlist .append (newsourcepath )
208
212
logging .info ("Разобран в %s" % (newsourcepath ))
209
213
@@ -219,10 +223,10 @@ def add_to_git(pathlists):
219
223
220
224
def compile (input , output , ext ):
221
225
import codecs
222
- if input is None :
223
- raise "Не указан путь к входящему каталогу"
224
- if output is None :
225
- raise "Не указан путь к исходящему файлу"
226
+
227
+ assert not input is None , "Не указан путь к входящему каталогу"
228
+ assert not output is None , "Не указан путь к исходящему файлу"
229
+
226
230
extfile = "epf" if ext == "auto" else ext
227
231
228
232
dirsource = os .path .abspath (os .path .join (os .path .curdir , input ))
@@ -238,33 +242,48 @@ def compile(input, output, ext):
238
242
lines = r .read ()
239
243
lines = lines .split ('\r \n ' )
240
244
for l in lines :
245
+ if l .startswith (u'\ufeff ' ):
246
+ l = l [1 :]
241
247
list = l .split ("-->" )
242
248
if len (list ) < 2 :
243
249
continue
244
- log .error (l )
250
+ log .debug (l )
245
251
newPath = os .path .join (tempPath , list [0 ])
246
252
dirname = os .path .dirname (newPath )
247
253
if not os .path .exists (dirname ):
248
254
os .mkdir (dirname )
249
- oldPath = os .path .join (dirsource , list [1 ].replace ("\\ " , os .path .sep ))
255
+ oldPath = os .path .join (dirsource ,
256
+ list [1 ].replace (
257
+ "\\ " , os .path .sep )
258
+ )
259
+
250
260
if os .path .isdir (oldPath ):
251
261
#tempFile = tempfile.mkstemp()
252
262
newPath = os .path .join (tempPath , list [0 ])
253
263
shutil .copytree (oldPath , newPath )
254
264
else :
255
- log .error (oldPath )
265
+ log .debug (oldPath )
256
266
shutil .copy (
257
267
os .path .normpath (oldPath ),
258
268
newPath
259
269
)
260
270
261
271
#вызовем v8unpack, для сборки файла из исходников.
262
272
tempFile = tempfile .mktemp ("." + extfile )
263
- log .debug (["UnpackV8.exe" , "-PACK" , '{}{}' .format (tempPath , os .path .sep ), tempFile ])
264
- log .error ('UnpackV8.exe -B "{}" "{}"' .format ('{}{}' .format (tempPath , os .path .sep ), tempFile ))
265
- result = subprocess .check_call (['UnpackV8.exe' , '-PACK' , '{}{}' .format (tempPath , os .path .sep ), tempFile ])
273
+ log .debug ('unpackv8 -B "{}" "{}"' .format ('{}' .format (tempPath ), tempFile ))
274
+ result = subprocess .check_call (
275
+ ['unpackv8' ,
276
+ '-B' ,
277
+ '{}' .format (tempPath ),
278
+ tempFile ]
279
+ )
280
+
281
+ log .debug ("copy from {} to {}" .format (tempFile , output ))
282
+ assert result == 0 , "Не удалось упаковать каталог {}" .format (tempPath )
266
283
shutil .move (tempFile , output )
267
284
285
+ return output
286
+
268
287
def main ():
269
288
270
289
parser = argparse .ArgumentParser (description = "Утилита \
0 commit comments