PyCatFile 0.17.2__tar.gz → 0.17.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pycatfile-0.17.2 → pycatfile-0.17.4}/PKG-INFO +1 -1
- {pycatfile-0.17.2 → pycatfile-0.17.4}/PyCatFile.egg-info/PKG-INFO +1 -1
- {pycatfile-0.17.2 → pycatfile-0.17.4}/catfile.py +1 -1
- {pycatfile-0.17.2 → pycatfile-0.17.4}/neocatfile.py +1 -1
- {pycatfile-0.17.2 → pycatfile-0.17.4}/pycatfile.py +152 -19
- {pycatfile-0.17.2 → pycatfile-0.17.4}/setup.py +1 -1
- {pycatfile-0.17.2 → pycatfile-0.17.4}/LICENSE +0 -0
- {pycatfile-0.17.2 → pycatfile-0.17.4}/PyCatFile.egg-info/SOURCES.txt +0 -0
- {pycatfile-0.17.2 → pycatfile-0.17.4}/PyCatFile.egg-info/dependency_links.txt +0 -0
- {pycatfile-0.17.2 → pycatfile-0.17.4}/PyCatFile.egg-info/top_level.txt +0 -0
- {pycatfile-0.17.2 → pycatfile-0.17.4}/PyCatFile.egg-info/zip-safe +0 -0
- {pycatfile-0.17.2 → pycatfile-0.17.4}/README.md +0 -0
- {pycatfile-0.17.2 → pycatfile-0.17.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.4
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.4
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: catfile.py - Last Update: 1/
|
|
17
|
+
$FileInfo: catfile.py - Last Update: 1/26/2025 Ver. 0.17.4 RC 1 - Author: cooldude2k $
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
20
|
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: neocatfile.py - Last Update: 1/
|
|
17
|
+
$FileInfo: neocatfile.py - Last Update: 1/26/2025 Ver. 0.17.4 RC 1 - Author: cooldude2k $
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
20
|
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: pycatfile.py - Last Update: 1/
|
|
17
|
+
$FileInfo: pycatfile.py - Last Update: 1/26/2025 Ver. 0.17.4 RC 1 - Author: cooldude2k $
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
20
|
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
@@ -286,7 +286,7 @@ __file_format_multi_dict__ = {}
|
|
|
286
286
|
__file_format_default__ = "CatFile"
|
|
287
287
|
__include_defaults__ = True
|
|
288
288
|
__program_name__ = "Py"+__file_format_default__
|
|
289
|
-
if os.path.exists(__config_file__)
|
|
289
|
+
if __use_ini_file__ and os.path.exists(__config_file__):
|
|
290
290
|
config = configparser.ConfigParser()
|
|
291
291
|
config.read(__config_file__)
|
|
292
292
|
def decode_unicode_escape(value):
|
|
@@ -305,18 +305,29 @@ if os.path.exists(__config_file__) and __use_ini_file__:
|
|
|
305
305
|
"newstyle", "advancedlist", "altinode"
|
|
306
306
|
]
|
|
307
307
|
if all(key in config[section] for key in required_keys):
|
|
308
|
-
__file_format_multi_dict__.update({decode_unicode_escape(config.get(section, 'magic')): {'format_name': decode_unicode_escape(config.get(section, 'name')), 'format_magic': decode_unicode_escape(config.get(section, 'magic')), 'format_lower': decode_unicode_escape(config.get(section, 'lower')), 'format_len': config.getint(section, 'len'), 'format_hex': config.get(section, 'hex'), 'format_delimiter': decode_unicode_escape(config.get(section, 'delimiter')), 'format_ver': config.get(section, 'ver'), 'new_style': config.getboolean(section, 'newstyle'), 'use_advanced_list': config.getboolean(section, 'advancedlist'), 'use_alt_inode': config.getboolean(section, 'altinode'), 'format_extension': decode_unicode_escape(config.get(section, 'extension')) } } )
|
|
308
|
+
__file_format_multi_dict__.update( { decode_unicode_escape(config.get(section, 'magic')): {'format_name': decode_unicode_escape(config.get(section, 'name')), 'format_magic': decode_unicode_escape(config.get(section, 'magic')), 'format_lower': decode_unicode_escape(config.get(section, 'lower')), 'format_len': config.getint(section, 'len'), 'format_hex': config.get(section, 'hex'), 'format_delimiter': decode_unicode_escape(config.get(section, 'delimiter')), 'format_ver': config.get(section, 'ver'), 'new_style': config.getboolean(section, 'newstyle'), 'use_advanced_list': config.getboolean(section, 'advancedlist'), 'use_alt_inode': config.getboolean(section, 'altinode'), 'format_extension': decode_unicode_escape(config.get(section, 'extension')) } } )
|
|
309
|
+
if not __file_format_multi_dict__ and not __include_defaults__:
|
|
310
|
+
__include_defaults__ = True
|
|
311
|
+
elif __use_ini_file__ and not os.path.exists(__config_file__):
|
|
312
|
+
__use_ini_file__ = False
|
|
313
|
+
__include_defaults__ = True
|
|
314
|
+
if not __use_ini_file__ and not __include_defaults__:
|
|
315
|
+
__include_defaults__ = True
|
|
309
316
|
if(__include_defaults__):
|
|
310
317
|
if("CatFile" not in __file_format_multi_dict__):
|
|
311
|
-
__file_format_multi_dict__.update({'CatFile': {'format_name': "CatFile", 'format_magic': "CatFile", 'format_lower': "catfile", 'format_len': 7, 'format_hex': "43617446696c65", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".cat" } } )
|
|
318
|
+
__file_format_multi_dict__.update( { 'CatFile': {'format_name': "CatFile", 'format_magic': "CatFile", 'format_lower': "catfile", 'format_len': 7, 'format_hex': "43617446696c65", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".cat" } } )
|
|
312
319
|
if("NekoFile" not in __file_format_multi_dict__):
|
|
313
|
-
__file_format_multi_dict__.update({'NekoFile': {'format_name': "NekoFile", 'format_magic': "NekoFile", 'format_lower': "nekofile", 'format_len': 8, 'format_hex': "4e656b6f46696c65", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".neko" } } )
|
|
320
|
+
__file_format_multi_dict__.update( { 'NekoFile': {'format_name': "NekoFile", 'format_magic': "NekoFile", 'format_lower': "nekofile", 'format_len': 8, 'format_hex': "4e656b6f46696c65", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".neko" } } )
|
|
314
321
|
if("ねこファイル" not in __file_format_multi_dict__):
|
|
315
|
-
__file_format_multi_dict__.update({'ねこファイル': {'format_name': "
|
|
322
|
+
__file_format_multi_dict__.update( { 'ねこファイル': {'format_name': "NekoFairu", 'format_magic': "ねこファイル", 'format_lower': "nekofairu", 'format_len': 18, 'format_hex': "e381ade38193e38395e382a1e382a4e383ab", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".ねこ" } } )
|
|
316
323
|
if("네코파일" not in __file_format_multi_dict__):
|
|
317
|
-
__file_format_multi_dict__.update({'네코파일': {'format_name': "
|
|
324
|
+
__file_format_multi_dict__.update( { '네코파일': {'format_name': "NekoPa-il", 'format_magic': "네코파일", 'format_lower': "nekopa-il", 'format_len': 12, 'format_hex': "eb84a4ecbd94ed8c8cec9dbc", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".네코" } } )
|
|
318
325
|
if("고양이파일" not in __file_format_multi_dict__):
|
|
319
|
-
__file_format_multi_dict__.update({'고양이파일': {'format_name': "
|
|
326
|
+
__file_format_multi_dict__.update( { '고양이파일': {'format_name': "GoyangiPa-il", 'format_magic': "고양이파일", 'format_lower': "goyangipa-il", 'format_len': 15, 'format_hex': "eab3a0ec9691ec9db4ed8c8cec9dbc", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".고양이" } } )
|
|
327
|
+
if("内酷法伊鲁" not in __file_format_multi_dict__):
|
|
328
|
+
__file_format_multi_dict__.update( { '内酷法伊鲁': {'format_name': "NèiKùFǎYīLǔ", 'format_magic': "内酷法伊鲁", 'format_lower': "nèikùfǎyīlǔ", 'format_len': 15, 'format_hex': "e58685e985b7e6b395e4bc8ae9b281", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".内酷" } } )
|
|
329
|
+
if("猫文件" not in __file_format_multi_dict__):
|
|
330
|
+
__file_format_multi_dict__.update( { '猫文件': {'format_name': "MāoWénjiàn", 'format_magic': "猫文件", 'format_lower': "māowénjiàn", 'format_len': 9, 'format_hex': "e78cabe69687e4bbb6", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".猫" } } )
|
|
320
331
|
if(__file_format_default__ not in __file_format_multi_dict__):
|
|
321
332
|
__file_format_default__ = next(iter(__file_format_multi_dict__))
|
|
322
333
|
__file_format_name__ = __file_format_multi_dict__[__file_format_default__]['format_name']
|
|
@@ -333,12 +344,12 @@ __file_format_extension__ = __file_format_multi_dict__[__file_format_default__][
|
|
|
333
344
|
__file_format_dict__ = __file_format_multi_dict__[__file_format_default__]
|
|
334
345
|
__project__ = __program_name__
|
|
335
346
|
__project_url__ = "https://github.com/GameMaker2k/PyCatFile"
|
|
336
|
-
__version_info__ = (0, 17,
|
|
337
|
-
__version_date_info__ = (2025, 1,
|
|
347
|
+
__version_info__ = (0, 17, 4, "RC 1", 1)
|
|
348
|
+
__version_date_info__ = (2025, 1, 26, "RC 1", 1)
|
|
338
349
|
__version_date__ = str(__version_date_info__[0]) + "." + str(
|
|
339
350
|
__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
|
|
340
351
|
__revision__ = __version_info__[3]
|
|
341
|
-
__revision_id__ = "$Id:
|
|
352
|
+
__revision_id__ = "$Id: baf38a80e3722546f3001e984ab1f032872f7568 $"
|
|
342
353
|
if(__version_info__[4] is not None):
|
|
343
354
|
__version_date_plusrc__ = __version_date__ + \
|
|
344
355
|
"-" + str(__version_date_info__[4])
|
|
@@ -2220,7 +2231,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2220
2231
|
return catlist
|
|
2221
2232
|
|
|
2222
2233
|
|
|
2223
|
-
def ReadFileHeaderDataWithContentToList(fp, listonly=False, uncompress=True, skipchecksum=False, formatspecs=__file_format_dict__):
|
|
2234
|
+
def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False, uncompress=True, skipchecksum=False, formatspecs=__file_format_dict__):
|
|
2224
2235
|
if(not hasattr(fp, "read")):
|
|
2225
2236
|
return False
|
|
2226
2237
|
delimiter = formatspecs['format_delimiter']
|
|
@@ -2338,7 +2349,8 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, uncompress=True, ski
|
|
|
2338
2349
|
else:
|
|
2339
2350
|
return False
|
|
2340
2351
|
fcontents.seek(0, 0)
|
|
2341
|
-
|
|
2352
|
+
if(not contentasfile):
|
|
2353
|
+
fcontents = fcontents.read()
|
|
2342
2354
|
catlist = [ftype, fencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression, fcsize, fuid, funame, fgid, fgname, fid,
|
|
2343
2355
|
finode, flinkcount, fdev, fdev_minor, fdev_major, fseeknextfile, extrafieldslist, HeaderOut[-4], HeaderOut[-3], fcontents]
|
|
2344
2356
|
return catlist
|
|
@@ -2535,7 +2547,7 @@ def ReadFileDataWithContentToArray(fp, seekstart=0, seekend=0, listonly=False, c
|
|
|
2535
2547
|
return catlist
|
|
2536
2548
|
|
|
2537
2549
|
|
|
2538
|
-
def ReadFileDataWithContentToList(fp, seekstart=0, seekend=0, listonly=False, uncompress=True, skipchecksum=False, formatspecs=__file_format_dict__):
|
|
2550
|
+
def ReadFileDataWithContentToList(fp, seekstart=0, seekend=0, listonly=False, contentasfile=False, uncompress=True, skipchecksum=False, formatspecs=__file_format_dict__):
|
|
2539
2551
|
if(not hasattr(fp, "read")):
|
|
2540
2552
|
return False
|
|
2541
2553
|
delimiter = formatspecs['format_delimiter']
|
|
@@ -2668,7 +2680,7 @@ def ReadFileDataWithContentToList(fp, seekstart=0, seekend=0, listonly=False, un
|
|
|
2668
2680
|
countnum = seekstart
|
|
2669
2681
|
while(countnum < seekend):
|
|
2670
2682
|
HeaderOut = ReadFileHeaderDataWithContentToList(
|
|
2671
|
-
fp, listonly, uncompress, skipchecksum, formatspecs)
|
|
2683
|
+
fp, listonly, contentasfile, uncompress, skipchecksum, formatspecs)
|
|
2672
2684
|
if(len(HeaderOut) == 0):
|
|
2673
2685
|
break
|
|
2674
2686
|
catlist.append(HeaderOut)
|
|
@@ -2851,7 +2863,21 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
2851
2863
|
return ReadFileDataWithContentToArray(fp, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs)
|
|
2852
2864
|
|
|
2853
2865
|
|
|
2854
|
-
def
|
|
2866
|
+
def ReadInMultipleFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__):
|
|
2867
|
+
if(isinstance(infile, (list, tuple, ))):
|
|
2868
|
+
pass
|
|
2869
|
+
else:
|
|
2870
|
+
infile = [infile]
|
|
2871
|
+
outretval = {}
|
|
2872
|
+
for curfname in infile:
|
|
2873
|
+
curretfile = outretval.update({curfname: ReadInFileWithContentToArray(curfname, fmttype, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs)})
|
|
2874
|
+
return outretval
|
|
2875
|
+
|
|
2876
|
+
def ReadInMultipleFilesWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__):
|
|
2877
|
+
return ReadInMultipleFileWithContentToArray(infile, fmttype, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs)
|
|
2878
|
+
|
|
2879
|
+
|
|
2880
|
+
def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__):
|
|
2855
2881
|
if(IsNestedDict(formatspecs) and fmttype!="auto" and fmttype in formatspecs):
|
|
2856
2882
|
formatspecs = formatspecs[fmttype]
|
|
2857
2883
|
elif(IsNestedDict(formatspecs) and fmttype!="auto" and fmttype not in formatspecs):
|
|
@@ -3022,7 +3048,21 @@ def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
3022
3048
|
if(not compresscheck):
|
|
3023
3049
|
return False
|
|
3024
3050
|
fp = UncompressFile(infile, formatspecs, "rb")
|
|
3025
|
-
return ReadFileDataWithContentToList(fp, seekstart, seekend, listonly, uncompress, skipchecksum, formatspecs)
|
|
3051
|
+
return ReadFileDataWithContentToList(fp, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs)
|
|
3052
|
+
|
|
3053
|
+
|
|
3054
|
+
def ReadInMultipleFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__):
|
|
3055
|
+
if(isinstance(infile, (list, tuple, ))):
|
|
3056
|
+
pass
|
|
3057
|
+
else:
|
|
3058
|
+
infile = [infile]
|
|
3059
|
+
outretval = {}
|
|
3060
|
+
for curfname in infile:
|
|
3061
|
+
curretfile = outretval.update({curfname: ReadInFileWithContentToList(curfname, fmttype, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs)})
|
|
3062
|
+
return outretval
|
|
3063
|
+
|
|
3064
|
+
def ReadInMultipleFilesWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__):
|
|
3065
|
+
return ReadInMultipleFileWithContentToList(infile, fmttype, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs)
|
|
3026
3066
|
|
|
3027
3067
|
|
|
3028
3068
|
def AppendNullByte(indata, delimiter=__file_format_dict__['format_delimiter']):
|
|
@@ -3454,6 +3494,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3454
3494
|
if ftype in data_types:
|
|
3455
3495
|
with open(fname, "rb") as fpc:
|
|
3456
3496
|
shutil.copyfileobj(fpc, fcontents)
|
|
3497
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
3457
3498
|
if(not compresswholefile):
|
|
3458
3499
|
fcontents.seek(0, 2)
|
|
3459
3500
|
ucfsize = fcontents.tell()
|
|
@@ -3608,6 +3649,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
|
|
|
3608
3649
|
fheaderchecksumtype = curfname[25]
|
|
3609
3650
|
fcontentchecksumtype = curfname[26]
|
|
3610
3651
|
fcontents = curfname[27]
|
|
3652
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
3611
3653
|
catoutlist = [ftype, fencoding, fname, flinkname, fsize, fatime, fmtime, fctime, fbtime, fmode, fwinattributes, fcompression, fcsize,
|
|
3612
3654
|
fuid, funame, fgid, fgname, fid, finode, flinkcount, fdev, fdev_minor, fdev_major, fseeknextfile]
|
|
3613
3655
|
fcontents.seek(0, 0)
|
|
@@ -3623,7 +3665,7 @@ def AppendListsWithContent(inlist, fp, dirlistfromtxt=False, filevalues=[], extr
|
|
|
3623
3665
|
|
|
3624
3666
|
|
|
3625
3667
|
def AppendInFileWithContent(infile, fp, dirlistfromtxt=False, filevalues=[], extradata=[], followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False):
|
|
3626
|
-
inlist = ReadInFileWithContentToList(infile, "auto", 0, 0, False, True, False, formatspecs)
|
|
3668
|
+
inlist = ReadInFileWithContentToList(infile, "auto", 0, 0, False, False, True, False, formatspecs)
|
|
3627
3669
|
return AppendListsWithContent(inlist, fp, dirlistfromtxt, filevalues, extradata, followlink, checksumtype, formatspecs, verbose)
|
|
3628
3670
|
|
|
3629
3671
|
|
|
@@ -3782,7 +3824,7 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
|
|
|
3782
3824
|
|
|
3783
3825
|
|
|
3784
3826
|
def AppendInFileWithContentToOutFile(infile, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, filevalues=[], extradata=[], followlink=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
3785
|
-
inlist = ReadInFileWithContentToList(infile, "auto", 0, 0, False, True, False, formatspecs)
|
|
3827
|
+
inlist = ReadInFileWithContentToList(infile, "auto", 0, 0, False, False, True, False, formatspecs)
|
|
3786
3828
|
return AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt, fmttype, compression, compresswholefile, compressionlevel, filevalues, extradata, followlink, checksumtype, formatspecs, verbose, returnfp)
|
|
3787
3829
|
|
|
3788
3830
|
|
|
@@ -3937,6 +3979,57 @@ def IsSingleDict(variable):
|
|
|
3937
3979
|
return True
|
|
3938
3980
|
|
|
3939
3981
|
|
|
3982
|
+
def GetFileEncoding(infile, closefp=True):
|
|
3983
|
+
if(hasattr(infile, "read") or hasattr(infile, "write")):
|
|
3984
|
+
fp = infile
|
|
3985
|
+
else:
|
|
3986
|
+
try:
|
|
3987
|
+
fp = open(infile, "rb")
|
|
3988
|
+
except FileNotFoundError:
|
|
3989
|
+
return False
|
|
3990
|
+
file_encoding = "UTF-8"
|
|
3991
|
+
fp.seek(0, 0)
|
|
3992
|
+
prefp = fp.read(2)
|
|
3993
|
+
if(prefp == binascii.unhexlify("fffe")):
|
|
3994
|
+
file_encoding = "UTF-16LE"
|
|
3995
|
+
elif(prefp == binascii.unhexlify("feff")):
|
|
3996
|
+
file_encoding = "UTF-16BE"
|
|
3997
|
+
fp.seek(0, 0)
|
|
3998
|
+
prefp = fp.read(3)
|
|
3999
|
+
if(prefp == binascii.unhexlify("efbbbf")):
|
|
4000
|
+
file_encoding = "UTF-8"
|
|
4001
|
+
elif(prefp == binascii.unhexlify("0efeff")):
|
|
4002
|
+
file_encoding = "SCSU"
|
|
4003
|
+
fp.seek(0, 0)
|
|
4004
|
+
prefp = fp.read(4)
|
|
4005
|
+
if(prefp == binascii.unhexlify("fffe0000")):
|
|
4006
|
+
file_encoding = "UTF-32LE"
|
|
4007
|
+
elif(prefp == binascii.unhexlify("0000feff")):
|
|
4008
|
+
file_encoding = "UTF-32BE"
|
|
4009
|
+
elif(prefp == binascii.unhexlify("dd736673")):
|
|
4010
|
+
file_encoding = "UTF-EBCDIC"
|
|
4011
|
+
elif(prefp == binascii.unhexlify("2b2f7638")):
|
|
4012
|
+
file_encoding = "UTF-7"
|
|
4013
|
+
elif(prefp == binascii.unhexlify("2b2f7639")):
|
|
4014
|
+
file_encoding = "UTF-7"
|
|
4015
|
+
elif(prefp == binascii.unhexlify("2b2f762b")):
|
|
4016
|
+
file_encoding = "UTF-7"
|
|
4017
|
+
elif(prefp == binascii.unhexlify("2b2f762f")):
|
|
4018
|
+
file_encoding = "UTF-7"
|
|
4019
|
+
fp.seek(0, 0)
|
|
4020
|
+
if(closefp):
|
|
4021
|
+
fp.close()
|
|
4022
|
+
return file_encoding
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
def GetFileEncodingFromString(instring, closefp=True):
|
|
4026
|
+
try:
|
|
4027
|
+
instringsfile = BytesIO(instring)
|
|
4028
|
+
except TypeError:
|
|
4029
|
+
instringsfile = BytesIO(instring.encode("UTF-8"))
|
|
4030
|
+
return GetFileEncoding(instringsfile, closefp)
|
|
4031
|
+
|
|
4032
|
+
|
|
3940
4033
|
def CheckCompressionType(infile, formatspecs=__file_format_multi_dict__, closefp=True):
|
|
3941
4034
|
if(hasattr(infile, "read") or hasattr(infile, "write")):
|
|
3942
4035
|
fp = infile
|
|
@@ -4829,6 +4922,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
|
|
|
4829
4922
|
if ftype in data_types:
|
|
4830
4923
|
with open(fname, "rb") as fpc:
|
|
4831
4924
|
shutil.copyfileobj(fpc, fcontents)
|
|
4925
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
4832
4926
|
if(not compresswholefile):
|
|
4833
4927
|
fcontents.seek(0, 2)
|
|
4834
4928
|
ucfsize = fcontents.tell()
|
|
@@ -5169,6 +5263,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5169
5263
|
if ftype in data_types:
|
|
5170
5264
|
fpc = tarfp.extractfile(member)
|
|
5171
5265
|
shutil.copyfileobj(fpc, fcontents)
|
|
5266
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
5172
5267
|
if(not compresswholefile):
|
|
5173
5268
|
fcontents.seek(0, 2)
|
|
5174
5269
|
ucfsize = fcontents.tell()
|
|
@@ -5461,6 +5556,7 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5461
5556
|
fcontents = BytesIO()
|
|
5462
5557
|
if(ftype == 0):
|
|
5463
5558
|
fcontents.write(zipfp.read(member.filename))
|
|
5559
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
5464
5560
|
if(not compresswholefile):
|
|
5465
5561
|
fcontents.seek(0, 2)
|
|
5466
5562
|
ucfsize = fcontents.tell()
|
|
@@ -5771,6 +5867,7 @@ if(rarfile_support):
|
|
|
5771
5867
|
fcontents = BytesIO()
|
|
5772
5868
|
if(ftype == 0):
|
|
5773
5869
|
fcontents.write(rarfp.read(member.filename))
|
|
5870
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
5774
5871
|
if(not compresswholefile):
|
|
5775
5872
|
fcontents.seek(0, 2)
|
|
5776
5873
|
ucfsize = fcontents.tell()
|
|
@@ -6018,6 +6115,7 @@ if(py7zr_support):
|
|
|
6018
6115
|
fcontents = BytesIO()
|
|
6019
6116
|
if(ftype == 0):
|
|
6020
6117
|
fcontents.write(file_content[member.filename].read())
|
|
6118
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
6021
6119
|
fsize = format(fcontents.tell(), 'x').lower()
|
|
6022
6120
|
file_content[member.filename].close()
|
|
6023
6121
|
if(not compresswholefile):
|
|
@@ -7032,6 +7130,21 @@ def ArchiveFileValidateFile(infile, fmttype="auto", formatspecs=__file_format_mu
|
|
|
7032
7130
|
return ArchiveFileValidate(infile, fmttype, formatspecs, verbose, returnfp)
|
|
7033
7131
|
|
|
7034
7132
|
|
|
7133
|
+
def ArchiveFileValidateMultiple(infile, fmttype="auto", formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
|
|
7134
|
+
if(isinstance(infile, (list, tuple, ))):
|
|
7135
|
+
pass
|
|
7136
|
+
else:
|
|
7137
|
+
infile = [infile]
|
|
7138
|
+
outretval = True
|
|
7139
|
+
for curfname in infile:
|
|
7140
|
+
curretfile = ArchiveFileValidate(curfname, fmttype, formatspecs, verbose, returnfp)
|
|
7141
|
+
if(not curretfile):
|
|
7142
|
+
outretval = False
|
|
7143
|
+
return outretval
|
|
7144
|
+
|
|
7145
|
+
def ArchiveFileValidateMultipleFiles(infile, fmttype="auto", formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
|
|
7146
|
+
return ArchiveFileValidateMultiple(infile, fmttype, formatspecs, verbose, returnfp)
|
|
7147
|
+
|
|
7035
7148
|
def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, returnfp=False):
|
|
7036
7149
|
if(IsNestedDict(formatspecs) and fmttype!="auto" and fmttype in formatspecs):
|
|
7037
7150
|
formatspecs = formatspecs[fmttype]
|
|
@@ -7413,6 +7526,20 @@ def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=
|
|
|
7413
7526
|
return catlist
|
|
7414
7527
|
|
|
7415
7528
|
|
|
7529
|
+
def MultipleArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, returnfp=False):
|
|
7530
|
+
if(isinstance(infile, (list, tuple, ))):
|
|
7531
|
+
pass
|
|
7532
|
+
else:
|
|
7533
|
+
infile = [infile]
|
|
7534
|
+
outretval = {}
|
|
7535
|
+
for curfname in infile:
|
|
7536
|
+
curretfile = outretval.update({curfname: ArchiveFileToArray(curfname, fmttype, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, returnfp)})
|
|
7537
|
+
return outretval
|
|
7538
|
+
|
|
7539
|
+
def MultipleArchiveFilesToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=False, contentasfile=True, uncompress=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, returnfp=False):
|
|
7540
|
+
return MultipleArchiveFileToArray(infile, fmttype, seekstart, seekend, listonly, contentasfile, uncompress, skipchecksum, formatspecs, returnfp)
|
|
7541
|
+
|
|
7542
|
+
|
|
7416
7543
|
def ArchiveFileStringToArray(catstr, seekstart=0, seekend=0, listonly=False, contentasfile=True, skipchecksum=False, formatspecs=__file_format_multi_dict__, returnfp=False):
|
|
7417
7544
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7418
7545
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
@@ -7739,6 +7866,7 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, fmttype=__file_format_defau
|
|
|
7739
7866
|
with open(fname, "rb") as fpc:
|
|
7740
7867
|
shutil.copyfileobj(fpc, fcontents)
|
|
7741
7868
|
fcsize = fcontents.tell()
|
|
7869
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
7742
7870
|
if(followlink and (ftype == 1 or ftype == 2)):
|
|
7743
7871
|
flstatinfo = os.stat(flinkname)
|
|
7744
7872
|
with open(flinkname, "rb") as fpc:
|
|
@@ -8030,6 +8158,7 @@ def TarFileToArrayAlt(infile, fmttype=__file_format_default__, listonly=False, c
|
|
|
8030
8158
|
fpc = tarfp.extractfile(member)
|
|
8031
8159
|
shutil.copyfileobj(fpc, fcontents)
|
|
8032
8160
|
fcsize = fcontents.tell()
|
|
8161
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
8033
8162
|
fcontents.seek(0, 0)
|
|
8034
8163
|
ftypehex = format(ftype, 'x').lower()
|
|
8035
8164
|
extrafields = len(extradata)
|
|
@@ -8311,6 +8440,7 @@ def ZipFileToArrayAlt(infile, fmttype=__file_format_default__, listonly=False, c
|
|
|
8311
8440
|
if(ftype == 0):
|
|
8312
8441
|
fcontents.write(zipfp.read(member.filename))
|
|
8313
8442
|
fcsize = fcontents.tell()
|
|
8443
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
8314
8444
|
fcontents.seek(0, 0)
|
|
8315
8445
|
ftypehex = format(ftype, 'x').lower()
|
|
8316
8446
|
extrafields = len(extradata)
|
|
@@ -8603,6 +8733,7 @@ if(rarfile_support):
|
|
|
8603
8733
|
if(ftype == 0):
|
|
8604
8734
|
fcontents.write(rarfp.read(member.filename))
|
|
8605
8735
|
fcsize = fcontents.tell()
|
|
8736
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
8606
8737
|
fcontents.seek(0, 0)
|
|
8607
8738
|
ftypehex = format(ftype, 'x').lower()
|
|
8608
8739
|
extrafields = len(extradata)
|
|
@@ -8840,6 +8971,7 @@ if(py7zr_support):
|
|
|
8840
8971
|
fsize = format(fcontents.tell(), 'x').lower()
|
|
8841
8972
|
fileop.close()
|
|
8842
8973
|
fcsize = fcontents.tell()
|
|
8974
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
8843
8975
|
fcontents.seek(0, 0)
|
|
8844
8976
|
ftypehex = format(ftype, 'x').lower()
|
|
8845
8977
|
extrafields = len(extradata)
|
|
@@ -9126,6 +9258,7 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
|
|
|
9126
9258
|
fcontents = listcatfiles['ffilelist'][reallcfi]['fcontents']
|
|
9127
9259
|
if(not listcatfiles['ffilelist'][reallcfi]['fcontentasfile']):
|
|
9128
9260
|
fcontents = BytesIO(fcontents)
|
|
9261
|
+
fencoding = GetFileEncoding(fcontents, False)
|
|
9129
9262
|
fcompression = ""
|
|
9130
9263
|
fcsize = format(int(0), 'x').lower()
|
|
9131
9264
|
if(not compresswholefile):
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
Copyright 2016-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
14
14
|
Copyright 2016-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
15
15
|
|
|
16
|
-
$FileInfo: setup.py - Last Update: 1/
|
|
16
|
+
$FileInfo: setup.py - Last Update: 1/26/2025 Ver. 0.17.4 RC 1 - Author: cooldude2k $
|
|
17
17
|
'''
|
|
18
18
|
|
|
19
19
|
import os
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|