@ -78,6 +78,8 @@ class _OutputFile:
if self . id_data . packed_file is not None :
if self . id_data . packed_file is not None :
self . file_data = self . id_data . packed_file . data
self . file_data = self . id_data . packed_file . data
else :
self . file_data = None
if self . file_type in ( _FileType . sdl , _FileType . python_code ) :
if self . file_type in ( _FileType . sdl , _FileType . python_code ) :
self . id_data = kwargs . get ( " id_data " )
self . id_data = kwargs . get ( " id_data " )
@ -358,13 +360,13 @@ class OutputFiles:
for i in self . _generate_files ( func ) :
for i in self . _generate_files ( func ) :
# Will only ever run for non-"dat" directories.
# Will only ever run for non-"dat" directories.
dst_path = str ( self . _export_path / i . dirname / i . filename )
dst_path = str ( self . _export_path / i . dirname / i . filename )
if i . file_path :
if i . file_data :
shutil . copy2 ( i . file_path , dst_path )
elif i . file_data :
mode = " w " if isinstance ( i . file_data , str ) else " wb "
mode = " w " if isinstance ( i . file_data , str ) else " wb "
with open ( dst_path , mode ) as handle :
with open ( dst_path , mode ) as handle :
handle . write ( i . file_data )
handle . write ( i . file_data )
os . utime ( dst_path , times )
os . utime ( dst_path , times )
elif i . file_path :
shutil . copy2 ( i . file_path , dst_path )
else :
else :
report . warn ( " No data found for dependency file ' {} ' . It will not be copied into the export directory. " ,
report . warn ( " No data found for dependency file ' {} ' . It will not be copied into the export directory. " ,
str ( i . dirname / i . filename ) , indent = 1 )
str ( i . dirname / i . filename ) , indent = 1 )
@ -410,15 +412,15 @@ class OutputFiles:
with zipfile . ZipFile ( str ( self . _export_file ) , ' w ' , zipfile . ZIP_DEFLATED ) as zf :
with zipfile . ZipFile ( str ( self . _export_file ) , ' w ' , zipfile . ZIP_DEFLATED ) as zf :
for i in self . _generate_files ( func ) :
for i in self . _generate_files ( func ) :
arcpath = i . filename if dat_only else " {} / {} " . format ( i . dirname , i . filename )
arcpath = i . filename if dat_only else " {} / {} " . format ( i . dirname , i . filename )
if i . file_path :
if i . file_data :
zf . write ( i . file_path , arcpath )
elif i . file_data :
if isinstance ( i . file_data , str ) :
if isinstance ( i . file_data , str ) :
data = i . file_data . encode ( _encoding )
data = i . file_data . encode ( _encoding )
else :
else :
data = i . file_data
data = i . file_data
zi = zipfile . ZipInfo ( arcpath , export_time )
zi = zipfile . ZipInfo ( arcpath , export_time )
zf . writestr ( zi , data )
zf . writestr ( zi , data )
elif i . file_path :
zf . write ( i . file_path , arcpath )
else :
else :
report . warn ( " No data found for dependency file ' {} ' . It will not be archived. " , arcpath , indent = 1 )
report . warn ( " No data found for dependency file ' {} ' . It will not be archived. " , arcpath , indent = 1 )