PyArchiveFile 0.21.2__py3-none-any.whl → 0.21.4__py3-none-any.whl
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.
- {pyarchivefile-0.21.2.data → pyarchivefile-0.21.4.data}/scripts/archivefile.py +1 -1
- {pyarchivefile-0.21.2.data → pyarchivefile-0.21.4.data}/scripts/neoarchivefile.py +1 -1
- {pyarchivefile-0.21.2.dist-info → pyarchivefile-0.21.4.dist-info}/METADATA +4 -4
- pyarchivefile-0.21.4.dist-info/RECORD +10 -0
- pyarchivefile.py +239 -145
- pyarchivefile-0.21.2.dist-info/RECORD +0 -10
- {pyarchivefile-0.21.2.data → pyarchivefile-0.21.4.data}/scripts/archiveneofile.py +0 -0
- {pyarchivefile-0.21.2.dist-info → pyarchivefile-0.21.4.dist-info}/WHEEL +0 -0
- {pyarchivefile-0.21.2.dist-info → pyarchivefile-0.21.4.dist-info}/licenses/LICENSE +0 -0
- {pyarchivefile-0.21.2.dist-info → pyarchivefile-0.21.4.dist-info}/top_level.txt +0 -0
- {pyarchivefile-0.21.2.dist-info → pyarchivefile-0.21.4.dist-info}/zip-safe +0 -0
|
@@ -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: archivefile.py - Last Update: 8/
|
|
17
|
+
$FileInfo: archivefile.py - Last Update: 8/26/2025 Ver. 0.21.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: neoarchivefile.py - Last Update:
|
|
17
|
+
$FileInfo: neoarchivefile.py - Last Update: 8/26/2025 Ver. 0.21.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
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyArchiveFile
|
|
3
|
-
Version: 0.21.
|
|
3
|
+
Version: 0.21.4
|
|
4
4
|
Summary: A tar like file format name archivefile.
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyArchiveFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyArchiveFile/archive/master.tar.gz
|
|
7
7
|
Author: Kazuki Przyborowski
|
|
8
|
-
Author-email: Kazuki Przyborowski <kazuki.przyborowski@gmail.com>
|
|
9
|
-
Maintainer: Kazuki
|
|
10
|
-
Maintainer-email: kazuki.
|
|
8
|
+
Author-email: Kazuki Przyborowski <kazuki.przyborowski@gmail.com>, Kazuki Suzuki Sadeghi <kazuki.suzuki.sadeghi@gmail.com>, Game Maker 2k <gamemaker2k@gmail.com>
|
|
9
|
+
Maintainer: Kazuki Suzuki Sadeghi
|
|
10
|
+
Maintainer-email: kazuki.suzuki.sadeghi@gmail.com
|
|
11
11
|
License: BSD-3-Clause
|
|
12
12
|
Platform: OS Independent
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
pyarchivefile.py,sha256=9nLbRmXcjHmEBgOtCV2uDE1KSrkU9TWXfk0wNBcAS4I,442766
|
|
2
|
+
pyarchivefile-0.21.4.data/scripts/archivefile.py,sha256=gHmFbiNTzafgYabt8joMUQfdoV4KuIBlMlghNltYVQQ,14410
|
|
3
|
+
pyarchivefile-0.21.4.data/scripts/archiveneofile.py,sha256=m2jQVSnpapc2fd9R1fyvvERCNT3JLKymcwE5_bl0Rfk,5140
|
|
4
|
+
pyarchivefile-0.21.4.data/scripts/neoarchivefile.py,sha256=wx4Ct6o3pnACJWhOFW9cLtoJ_e_alIWIj29Iey5Eb1w,7334
|
|
5
|
+
pyarchivefile-0.21.4.dist-info/licenses/LICENSE,sha256=WM1VWxTUVrQbvEa-LC7cKTaBHXiqSTyYPoJvsZSbd7E,1513
|
|
6
|
+
pyarchivefile-0.21.4.dist-info/METADATA,sha256=dpxSb2l-3oY5IftghKzm2ZvSgjfo8cFQfzMpgLaAg8c,835
|
|
7
|
+
pyarchivefile-0.21.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
pyarchivefile-0.21.4.dist-info/top_level.txt,sha256=dXsHVLesKNVXuVZeri6pRuRPo3y1HrcPsUrIw5KU5fk,14
|
|
9
|
+
pyarchivefile-0.21.4.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
10
|
+
pyarchivefile-0.21.4.dist-info/RECORD,,
|
pyarchivefile.py
CHANGED
|
@@ -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: pyarchivefile.py - Last Update: 8/
|
|
17
|
+
$FileInfo: pyarchivefile.py - Last Update: 8/26/2025 Ver. 0.21.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
|
|
@@ -32,10 +32,12 @@ import socket
|
|
|
32
32
|
import hashlib
|
|
33
33
|
import inspect
|
|
34
34
|
import datetime
|
|
35
|
+
import tempfile
|
|
35
36
|
import logging
|
|
36
37
|
import zipfile
|
|
37
38
|
import binascii
|
|
38
39
|
import platform
|
|
40
|
+
from io import StringIO, BytesIO
|
|
39
41
|
try:
|
|
40
42
|
from backports import tempfile
|
|
41
43
|
except ImportError:
|
|
@@ -243,17 +245,6 @@ except ImportError:
|
|
|
243
245
|
from urllib2 import Request, build_opener, HTTPBasicAuthHandler
|
|
244
246
|
from urlparse import urlparse
|
|
245
247
|
|
|
246
|
-
# StringIO and BytesIO
|
|
247
|
-
try:
|
|
248
|
-
from io import StringIO, BytesIO
|
|
249
|
-
except ImportError:
|
|
250
|
-
try:
|
|
251
|
-
from cStringIO import StringIO
|
|
252
|
-
from cStringIO import StringIO as BytesIO
|
|
253
|
-
except ImportError:
|
|
254
|
-
from StringIO import StringIO
|
|
255
|
-
from StringIO import StringIO as BytesIO
|
|
256
|
-
|
|
257
248
|
def get_importing_script_path():
|
|
258
249
|
# Inspect the stack and get the frame of the caller
|
|
259
250
|
stack = inspect.stack()
|
|
@@ -275,22 +266,6 @@ def get_default_threads():
|
|
|
275
266
|
|
|
276
267
|
|
|
277
268
|
__use_pysftp__ = False
|
|
278
|
-
__use_alt_format__ = False
|
|
279
|
-
__use_env_file__ = True
|
|
280
|
-
__use_ini_file__ = True
|
|
281
|
-
__use_ini_name__ = "archivefile.ini"
|
|
282
|
-
if('PYARCHIVEFILE_CONFIG_FILE' in os.environ and os.path.exists(os.environ['PYARCHIVEFILE_CONFIG_FILE']) and __use_env_file__):
|
|
283
|
-
scriptconf = os.environ['PYARCHIVEFILE_CONFIG_FILE']
|
|
284
|
-
else:
|
|
285
|
-
prescriptpath = get_importing_script_path()
|
|
286
|
-
if(prescriptpath is not None):
|
|
287
|
-
scriptconf = os.path.join(os.path.dirname(prescriptpath), __use_ini_name__)
|
|
288
|
-
else:
|
|
289
|
-
scriptconf = ""
|
|
290
|
-
if os.path.exists(scriptconf):
|
|
291
|
-
__config_file__ = scriptconf
|
|
292
|
-
else:
|
|
293
|
-
__config_file__ = os.path.join(os.path.dirname(os.path.realpath(__file__)), __use_ini_name__)
|
|
294
269
|
if(not havepysftp):
|
|
295
270
|
__use_pysftp__ = False
|
|
296
271
|
__use_http_lib__ = "httpx"
|
|
@@ -328,7 +303,25 @@ def is_only_nonprintable(var):
|
|
|
328
303
|
__file_format_multi_dict__ = {}
|
|
329
304
|
__file_format_default__ = "ArchiveFile"
|
|
330
305
|
__include_defaults__ = True
|
|
306
|
+
__use_inmemfile__ = False
|
|
331
307
|
__program_name__ = "Py"+__file_format_default__
|
|
308
|
+
__use_env_file__ = True
|
|
309
|
+
__use_ini_file__ = False
|
|
310
|
+
__use_ini_name__ = "archivefile.ini"
|
|
311
|
+
__use_json_file__ = False
|
|
312
|
+
__use_json_name__ = "archivefile.json"
|
|
313
|
+
if('PYARCHIVEFILE_CONFIG_FILE' in os.environ and os.path.exists(os.environ['PYARCHIVEFILE_CONFIG_FILE']) and __use_env_file__):
|
|
314
|
+
scriptconf = os.environ['PYARCHIVEFILE_CONFIG_FILE']
|
|
315
|
+
else:
|
|
316
|
+
prescriptpath = get_importing_script_path()
|
|
317
|
+
if(prescriptpath is not None):
|
|
318
|
+
scriptconf = os.path.join(os.path.dirname(prescriptpath), __use_ini_name__)
|
|
319
|
+
else:
|
|
320
|
+
scriptconf = ""
|
|
321
|
+
if os.path.exists(scriptconf):
|
|
322
|
+
__config_file__ = scriptconf
|
|
323
|
+
else:
|
|
324
|
+
__config_file__ = os.path.join(os.path.dirname(os.path.realpath(__file__)), __use_ini_name__)
|
|
332
325
|
if __use_ini_file__ and os.path.exists(__config_file__):
|
|
333
326
|
config = configparser.ConfigParser()
|
|
334
327
|
config.read(__config_file__)
|
|
@@ -340,6 +333,7 @@ if __use_ini_file__ and os.path.exists(__config_file__):
|
|
|
340
333
|
__file_format_default__ = decode_unicode_escape(config.get('config', 'default'))
|
|
341
334
|
__program_name__ = decode_unicode_escape(config.get('config', 'proname'))
|
|
342
335
|
__include_defaults__ = config.getboolean('config', 'includedef')
|
|
336
|
+
__use_inmemfile__ = config.getboolean('config', 'inmemfile')
|
|
343
337
|
# Loop through all sections
|
|
344
338
|
for section in config.sections():
|
|
345
339
|
required_keys = [
|
|
@@ -379,12 +373,12 @@ __file_format_extension__ = __file_format_multi_dict__[__file_format_default__][
|
|
|
379
373
|
__file_format_dict__ = __file_format_multi_dict__[__file_format_default__]
|
|
380
374
|
__project__ = __program_name__
|
|
381
375
|
__project_url__ = "https://github.com/GameMaker2k/PyArchiveFile"
|
|
382
|
-
__version_info__ = (0, 21,
|
|
383
|
-
__version_date_info__ = (2025, 9,
|
|
376
|
+
__version_info__ = (0, 21, 4, "RC 1", 1)
|
|
377
|
+
__version_date_info__ = (2025, 9, 26, "RC 1", 1)
|
|
384
378
|
__version_date__ = str(__version_date_info__[0]) + "." + str(
|
|
385
379
|
__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
|
|
386
380
|
__revision__ = __version_info__[3]
|
|
387
|
-
__revision_id__ = "$Id:
|
|
381
|
+
__revision_id__ = "$Id: 51621a2b361db767bc985f415869721fb7be5e6c $"
|
|
388
382
|
if(__version_info__[4] is not None):
|
|
389
383
|
__version_date_plusrc__ = __version_date__ + \
|
|
390
384
|
"-" + str(__version_date_info__[4])
|
|
@@ -574,6 +568,105 @@ def VerbosePrintOutReturn(dbgtxt, outtype="log", dbgenable=True, dgblevel=20):
|
|
|
574
568
|
return dbgtxt
|
|
575
569
|
|
|
576
570
|
|
|
571
|
+
# --- Helpers ---
|
|
572
|
+
def _normalize_initial_data(data, isbytes, encoding):
|
|
573
|
+
"""Return data in the correct type for write(): bytes (if isbytes) or text (if not)."""
|
|
574
|
+
if data is None:
|
|
575
|
+
return None
|
|
576
|
+
|
|
577
|
+
if isbytes:
|
|
578
|
+
# Want bytes
|
|
579
|
+
if isinstance(data, bytes):
|
|
580
|
+
return data
|
|
581
|
+
# Py2: str is already bytes, unicode needs encode
|
|
582
|
+
if sys.version_info[0] == 2:
|
|
583
|
+
try:
|
|
584
|
+
unicode # noqa: F821
|
|
585
|
+
except NameError:
|
|
586
|
+
pass
|
|
587
|
+
else:
|
|
588
|
+
if isinstance(data, unicode): # noqa: F821
|
|
589
|
+
return data.encode(encoding)
|
|
590
|
+
# Py3 str -> encode
|
|
591
|
+
return str(data).encode(encoding)
|
|
592
|
+
else:
|
|
593
|
+
# Want text (unicode/str)
|
|
594
|
+
if sys.version_info[0] == 2:
|
|
595
|
+
try:
|
|
596
|
+
unicode # noqa: F821
|
|
597
|
+
if isinstance(data, unicode): # noqa: F821
|
|
598
|
+
return data
|
|
599
|
+
# bytes/str -> decode
|
|
600
|
+
return data.decode(encoding) if isinstance(data, str) else unicode(data) # noqa: F821
|
|
601
|
+
except NameError:
|
|
602
|
+
# Very defensive; shouldn't happen
|
|
603
|
+
return data
|
|
604
|
+
else:
|
|
605
|
+
# Py3: want str
|
|
606
|
+
if isinstance(data, bytes):
|
|
607
|
+
return data.decode(encoding)
|
|
608
|
+
return str(data)
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
def MkTempFile(data=None, inmem=__use_inmemfile__, isbytes=True, prefix=__project__,
|
|
612
|
+
delete=True, encoding="utf-8"):
|
|
613
|
+
"""
|
|
614
|
+
Return a file-like handle.
|
|
615
|
+
- If inmem=True: returns StringIO (text) or BytesIO (bytes).
|
|
616
|
+
- If inmem=False: returns a NamedTemporaryFile opened in text or binary mode.
|
|
617
|
+
Args:
|
|
618
|
+
data: optional initial content; if provided, it's written and the handle is seek(0)
|
|
619
|
+
inmem: bool — return in-memory handle if True
|
|
620
|
+
isbytes: bool — choose bytes (True) or text (False)
|
|
621
|
+
prefix: str — tempfile prefix
|
|
622
|
+
delete: bool — whether the tempfile is deleted on close (NamedTemporaryFile)
|
|
623
|
+
encoding: str — used for text mode (and for conversions when needed)
|
|
624
|
+
"""
|
|
625
|
+
init = _normalize_initial_data(data, isbytes, encoding)
|
|
626
|
+
|
|
627
|
+
if inmem:
|
|
628
|
+
buf = BytesIO() if isbytes else StringIO()
|
|
629
|
+
if init is not None:
|
|
630
|
+
buf.write(init)
|
|
631
|
+
buf.seek(0)
|
|
632
|
+
return buf
|
|
633
|
+
|
|
634
|
+
mode = "wb+" if isbytes else "w+"
|
|
635
|
+
kwargs = {"prefix": prefix or "", "delete": delete, "mode": mode}
|
|
636
|
+
|
|
637
|
+
# Only Python 3's text-mode files accept encoding/newline explicitly
|
|
638
|
+
if not isbytes and sys.version_info[0] >= 3:
|
|
639
|
+
kwargs["encoding"] = encoding
|
|
640
|
+
kwargs["newline"] = ""
|
|
641
|
+
|
|
642
|
+
f = tempfile.NamedTemporaryFile(**kwargs)
|
|
643
|
+
|
|
644
|
+
if init is not None:
|
|
645
|
+
f.write(init)
|
|
646
|
+
f.seek(0)
|
|
647
|
+
return f
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
def MkTempFileSmart(data=None, isbytes=True, prefix=__project__, max_mem=1024*1024, encoding="utf-8"):
|
|
651
|
+
"""
|
|
652
|
+
Spooled temp file: starts in memory and spills to disk past max_mem.
|
|
653
|
+
Behaves like BytesIO/StringIO for small data, with the same preload+seek(0) behavior.
|
|
654
|
+
"""
|
|
655
|
+
mode = "wb+" if isbytes else "w+"
|
|
656
|
+
kwargs = {"mode": mode, "max_size": max_mem, "prefix": prefix or ""}
|
|
657
|
+
if not isbytes and sys.version_info[0] >= 3:
|
|
658
|
+
kwargs["encoding"] = encoding
|
|
659
|
+
kwargs["newline"] = ""
|
|
660
|
+
|
|
661
|
+
f = tempfile.SpooledTemporaryFile(**kwargs)
|
|
662
|
+
|
|
663
|
+
init = _normalize_initial_data(data, isbytes, encoding)
|
|
664
|
+
if init is not None:
|
|
665
|
+
f.write(init)
|
|
666
|
+
f.seek(0)
|
|
667
|
+
return f
|
|
668
|
+
|
|
669
|
+
|
|
577
670
|
def RemoveWindowsPath(dpath):
|
|
578
671
|
"""
|
|
579
672
|
Normalize a path by converting backslashes to forward slashes
|
|
@@ -1910,7 +2003,7 @@ def ReadFileHeaderDataBySize(fp, delimiter=__file_format_dict__['format_delimite
|
|
|
1910
2003
|
headersize = int(preheaderdata[0], 16)
|
|
1911
2004
|
if(headersize <= 0):
|
|
1912
2005
|
return []
|
|
1913
|
-
subfp =
|
|
2006
|
+
subfp = MkTempFile()
|
|
1914
2007
|
subfp.write(fp.read(headersize))
|
|
1915
2008
|
fp.seek(len(delimiter), 1)
|
|
1916
2009
|
subfp.seek(0, 0)
|
|
@@ -1994,7 +2087,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
|
|
|
1994
2087
|
return False
|
|
1995
2088
|
fhend = fp.tell() - 1
|
|
1996
2089
|
fcontentstart = fp.tell()
|
|
1997
|
-
fcontents =
|
|
2090
|
+
fcontents = MkTempFile()
|
|
1998
2091
|
if(fsize > 0 and not listonly):
|
|
1999
2092
|
if(fcompression == "none" or fcompression == "" or fcompression == "auto"):
|
|
2000
2093
|
fcontents.write(fp.read(fsize))
|
|
@@ -2021,7 +2114,7 @@ def ReadFileHeaderDataWithContent(fp, listonly=False, uncompress=True, skipcheck
|
|
|
2021
2114
|
if(uncompress):
|
|
2022
2115
|
cfcontents = UncompressFileAlt(fcontents, formatspecs)
|
|
2023
2116
|
cfcontents.seek(0, 0)
|
|
2024
|
-
fcontents =
|
|
2117
|
+
fcontents = MkTempFile()
|
|
2025
2118
|
shutil.copyfileobj(cfcontents, fcontents)
|
|
2026
2119
|
cfcontents.close()
|
|
2027
2120
|
fcontents.seek(0, 0)
|
|
@@ -2135,7 +2228,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2135
2228
|
fjsoncontent = {}
|
|
2136
2229
|
elif(fjsontype=="list"):
|
|
2137
2230
|
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
|
|
2138
|
-
flisttmp =
|
|
2231
|
+
flisttmp = MkTempFile()
|
|
2139
2232
|
flisttmp.write(fprejsoncontent.encode())
|
|
2140
2233
|
flisttmp.seek(0)
|
|
2141
2234
|
fjsoncontent = ReadFileHeaderData(flisttmp, fjsonlen, delimiter)
|
|
@@ -2171,7 +2264,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2171
2264
|
return False
|
|
2172
2265
|
fhend = fp.tell() - 1
|
|
2173
2266
|
fcontentstart = fp.tell()
|
|
2174
|
-
fcontents =
|
|
2267
|
+
fcontents = MkTempFile()
|
|
2175
2268
|
pyhascontents = False
|
|
2176
2269
|
if(fsize > 0 and not listonly):
|
|
2177
2270
|
if(fcompression == "none" or fcompression == "" or fcompression == "auto"):
|
|
@@ -2202,7 +2295,7 @@ def ReadFileHeaderDataWithContentToArray(fp, listonly=False, contentasfile=True,
|
|
|
2202
2295
|
cfcontents = UncompressFileAlt(
|
|
2203
2296
|
fcontents, formatspecs)
|
|
2204
2297
|
cfcontents.seek(0, 0)
|
|
2205
|
-
fcontents =
|
|
2298
|
+
fcontents = MkTempFile()
|
|
2206
2299
|
shutil.copyfileobj(cfcontents, fcontents)
|
|
2207
2300
|
cfcontents.close()
|
|
2208
2301
|
fcontents.seek(0, 0)
|
|
@@ -2321,7 +2414,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2321
2414
|
fjsoncontent = {}
|
|
2322
2415
|
elif(fjsontype=="list"):
|
|
2323
2416
|
fprejsoncontent = fp.read(fjsonsize).decode("UTF-8")
|
|
2324
|
-
flisttmp =
|
|
2417
|
+
flisttmp = MkTempFile()
|
|
2325
2418
|
flisttmp.write(fprejsoncontent.encode())
|
|
2326
2419
|
flisttmp.seek(0)
|
|
2327
2420
|
fjsoncontent = ReadFileHeaderData(flisttmp, fjsonlen, delimiter)
|
|
@@ -2356,7 +2449,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2356
2449
|
return False
|
|
2357
2450
|
fhend = fp.tell() - 1
|
|
2358
2451
|
fcontentstart = fp.tell()
|
|
2359
|
-
fcontents =
|
|
2452
|
+
fcontents = MkTempFile()
|
|
2360
2453
|
pyhascontents = False
|
|
2361
2454
|
if(fsize > 0 and not listonly):
|
|
2362
2455
|
if(fcompression == "none" or fcompression == "" or fcompression == "auto"):
|
|
@@ -2386,7 +2479,7 @@ def ReadFileHeaderDataWithContentToList(fp, listonly=False, contentasfile=False,
|
|
|
2386
2479
|
cfcontents = UncompressFileAlt(
|
|
2387
2480
|
fcontents, formatspecs)
|
|
2388
2481
|
cfcontents.seek(0, 0)
|
|
2389
|
-
fcontents =
|
|
2482
|
+
fcontents = MkTempFile()
|
|
2390
2483
|
shutil.copyfileobj(cfcontents, fcontents)
|
|
2391
2484
|
cfcontents.close()
|
|
2392
2485
|
fcontents.seek(0, 0)
|
|
@@ -2586,7 +2679,7 @@ def ReadFileDataWithContentToArray(fp, seekstart=0, seekend=0, listonly=False, c
|
|
|
2586
2679
|
invalid_archive = True
|
|
2587
2680
|
prefhend = fp.tell() - 1
|
|
2588
2681
|
prefcontentstart = fp.tell()
|
|
2589
|
-
prefcontents =
|
|
2682
|
+
prefcontents = MkTempFile()
|
|
2590
2683
|
pyhascontents = False
|
|
2591
2684
|
if(prefsize > 0):
|
|
2592
2685
|
prefcontents.write(fp.read(prefsize))
|
|
@@ -2854,7 +2947,7 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
2854
2947
|
return False
|
|
2855
2948
|
fp.seek(0, 0)
|
|
2856
2949
|
elif(infile == "-"):
|
|
2857
|
-
fp =
|
|
2950
|
+
fp = MkTempFile()
|
|
2858
2951
|
if(hasattr(sys.stdin, "buffer")):
|
|
2859
2952
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
2860
2953
|
else:
|
|
@@ -2875,7 +2968,7 @@ def ReadInFileWithContentToArray(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
2875
2968
|
return False
|
|
2876
2969
|
fp.seek(0, 0)
|
|
2877
2970
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
2878
|
-
fp =
|
|
2971
|
+
fp = MkTempFile()
|
|
2879
2972
|
fp.write(infile)
|
|
2880
2973
|
fp.seek(0, 0)
|
|
2881
2974
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -3042,7 +3135,7 @@ def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
3042
3135
|
return False
|
|
3043
3136
|
fp.seek(0, 0)
|
|
3044
3137
|
elif(infile == "-"):
|
|
3045
|
-
fp =
|
|
3138
|
+
fp = MkTempFile()
|
|
3046
3139
|
if(hasattr(sys.stdin, "buffer")):
|
|
3047
3140
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
3048
3141
|
else:
|
|
@@ -3063,7 +3156,7 @@ def ReadInFileWithContentToList(infile, fmttype="auto", seekstart=0, seekend=0,
|
|
|
3063
3156
|
return False
|
|
3064
3157
|
fp.seek(0, 0)
|
|
3065
3158
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
3066
|
-
fp =
|
|
3159
|
+
fp = MkTempFile()
|
|
3067
3160
|
fp.write(infile)
|
|
3068
3161
|
fp.seek(0, 0)
|
|
3069
3162
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -3298,11 +3391,11 @@ def MakeEmptyFile(outfile, fmttype="auto", compression="auto", compresswholefile
|
|
|
3298
3391
|
pass
|
|
3299
3392
|
if(outfile == "-" or outfile is None):
|
|
3300
3393
|
verbose = False
|
|
3301
|
-
fp =
|
|
3394
|
+
fp = MkTempFile()
|
|
3302
3395
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3303
3396
|
fp = outfile
|
|
3304
3397
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
3305
|
-
fp =
|
|
3398
|
+
fp = MkTempFile()
|
|
3306
3399
|
else:
|
|
3307
3400
|
fbasename = os.path.splitext(outfile)[0]
|
|
3308
3401
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -3634,7 +3727,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3634
3727
|
fwinattributes = format(int(0), 'x').lower()
|
|
3635
3728
|
fcompression = ""
|
|
3636
3729
|
fcsize = format(int(0), 'x').lower()
|
|
3637
|
-
fcontents =
|
|
3730
|
+
fcontents = MkTempFile()
|
|
3638
3731
|
chunk_size = 1024
|
|
3639
3732
|
fcencoding = "UTF-8"
|
|
3640
3733
|
curcompression = "none"
|
|
@@ -3653,7 +3746,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3653
3746
|
ilmin = 0
|
|
3654
3747
|
ilcsize = []
|
|
3655
3748
|
while(ilmin < ilsize):
|
|
3656
|
-
cfcontents =
|
|
3749
|
+
cfcontents = MkTempFile()
|
|
3657
3750
|
fcontents.seek(0, 0)
|
|
3658
3751
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
3659
3752
|
fcontents.seek(0, 0)
|
|
@@ -3670,7 +3763,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3670
3763
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
3671
3764
|
curcompression = compressionuselist[ilcmin]
|
|
3672
3765
|
fcontents.seek(0, 0)
|
|
3673
|
-
cfcontents =
|
|
3766
|
+
cfcontents = MkTempFile()
|
|
3674
3767
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
3675
3768
|
cfcontents.seek(0, 0)
|
|
3676
3769
|
cfcontents = CompressOpenFileAlt(
|
|
@@ -3700,7 +3793,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3700
3793
|
ilmin = 0
|
|
3701
3794
|
ilcsize = []
|
|
3702
3795
|
while(ilmin < ilsize):
|
|
3703
|
-
cfcontents =
|
|
3796
|
+
cfcontents = MkTempFile()
|
|
3704
3797
|
fcontents.seek(0, 0)
|
|
3705
3798
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
3706
3799
|
fcontents.seek(0, 0)
|
|
@@ -3717,7 +3810,7 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
|
|
|
3717
3810
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
3718
3811
|
curcompression = compressionuselist[ilcmin]
|
|
3719
3812
|
fcontents.seek(0, 0)
|
|
3720
|
-
cfcontents =
|
|
3813
|
+
cfcontents = MkTempFile()
|
|
3721
3814
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
3722
3815
|
cfcontents.seek(0, 0)
|
|
3723
3816
|
cfcontents = CompressOpenFileAlt(
|
|
@@ -3847,11 +3940,11 @@ def AppendFilesWithContentToOutFile(infiles, outfile, dirlistfromtxt=False, fmtt
|
|
|
3847
3940
|
pass
|
|
3848
3941
|
if(outfile == "-" or outfile is None):
|
|
3849
3942
|
verbose = False
|
|
3850
|
-
fp =
|
|
3943
|
+
fp = MkTempFile()
|
|
3851
3944
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3852
3945
|
fp = outfile
|
|
3853
3946
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
3854
|
-
fp =
|
|
3947
|
+
fp = MkTempFile()
|
|
3855
3948
|
else:
|
|
3856
3949
|
fbasename = os.path.splitext(outfile)[0]
|
|
3857
3950
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -3927,11 +4020,11 @@ def AppendListsWithContentToOutFile(inlist, outfile, dirlistfromtxt=False, fmtty
|
|
|
3927
4020
|
pass
|
|
3928
4021
|
if(outfile == "-" or outfile is None):
|
|
3929
4022
|
verbose = False
|
|
3930
|
-
fp =
|
|
4023
|
+
fp = MkTempFile()
|
|
3931
4024
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
3932
4025
|
fp = outfile
|
|
3933
4026
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
3934
|
-
fp =
|
|
4027
|
+
fp = MkTempFile()
|
|
3935
4028
|
else:
|
|
3936
4029
|
fbasename = os.path.splitext(outfile)[0]
|
|
3937
4030
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -4048,7 +4141,7 @@ def GzipCompressData(data, compresslevel=9):
|
|
|
4048
4141
|
compressed_data = gzip.compress(data, compresslevel=compresslevel)
|
|
4049
4142
|
except AttributeError:
|
|
4050
4143
|
# Fallback to older method for Python 2.x and older 3.x versions
|
|
4051
|
-
out =
|
|
4144
|
+
out = MkTempFile()
|
|
4052
4145
|
with gzip.GzipFile(fileobj=out, mode="wb", compresslevel=compresslevel) as f:
|
|
4053
4146
|
f.write(data)
|
|
4054
4147
|
compressed_data = out.getvalue()
|
|
@@ -4061,7 +4154,7 @@ def GzipDecompressData(compressed_data):
|
|
|
4061
4154
|
decompressed_data = gzip.decompress(compressed_data)
|
|
4062
4155
|
except AttributeError:
|
|
4063
4156
|
# Fallback to older method for Python 2.x and older 3.x versions
|
|
4064
|
-
inp =
|
|
4157
|
+
inp = MkTempFile(compressed_data)
|
|
4065
4158
|
with gzip.GzipFile(fileobj=inp, mode="rb") as f:
|
|
4066
4159
|
decompressed_data = f.read()
|
|
4067
4160
|
return decompressed_data
|
|
@@ -4194,9 +4287,9 @@ def GetFileEncoding(infile, closefp=True):
|
|
|
4194
4287
|
|
|
4195
4288
|
def GetFileEncodingFromString(instring, closefp=True):
|
|
4196
4289
|
try:
|
|
4197
|
-
instringsfile =
|
|
4290
|
+
instringsfile = MkTempFile(instring)
|
|
4198
4291
|
except TypeError:
|
|
4199
|
-
instringsfile =
|
|
4292
|
+
instringsfile = MkTempFile(instring.encode("UTF-8"))
|
|
4200
4293
|
return GetFileEncoding(instringsfile, closefp)
|
|
4201
4294
|
|
|
4202
4295
|
|
|
@@ -4459,17 +4552,17 @@ def CheckCompressionSubType(infile, formatspecs=__file_format_multi_dict__, clos
|
|
|
4459
4552
|
|
|
4460
4553
|
def CheckCompressionTypeFromString(instring, formatspecs=__file_format_multi_dict__, closefp=True):
|
|
4461
4554
|
try:
|
|
4462
|
-
instringsfile =
|
|
4555
|
+
instringsfile = MkTempFile(instring)
|
|
4463
4556
|
except TypeError:
|
|
4464
|
-
instringsfile =
|
|
4557
|
+
instringsfile = MkTempFile(instring.encode("UTF-8"))
|
|
4465
4558
|
return CheckCompressionType(instringsfile, formatspecs, closefp)
|
|
4466
4559
|
|
|
4467
4560
|
|
|
4468
4561
|
def CheckCompressionTypeFromBytes(instring, formatspecs=__file_format_multi_dict__, closefp=True):
|
|
4469
4562
|
try:
|
|
4470
|
-
instringsfile =
|
|
4563
|
+
instringsfile = MkTempFile(instring)
|
|
4471
4564
|
except TypeError:
|
|
4472
|
-
instringsfile =
|
|
4565
|
+
instringsfile = MkTempFile(instring.decode("UTF-8"))
|
|
4473
4566
|
return CheckCompressionType(instringsfile, formatspecs, closefp)
|
|
4474
4567
|
|
|
4475
4568
|
|
|
@@ -4636,7 +4729,7 @@ def UncompressBytes(infile, formatspecs=__file_format_multi_dict__):
|
|
|
4636
4729
|
|
|
4637
4730
|
|
|
4638
4731
|
def UncompressBytesAlt(inbytes, formatspecs=__file_format_multi_dict__):
|
|
4639
|
-
filefp =
|
|
4732
|
+
filefp = MkTempFile()
|
|
4640
4733
|
outstring = UncompressBytes(inbytes, formatspecs)
|
|
4641
4734
|
filefp.write(outstring)
|
|
4642
4735
|
filefp.seek(0, 0)
|
|
@@ -4652,7 +4745,7 @@ def UncompressBytesAltFP(fp, formatspecs=__file_format_multi_dict__):
|
|
|
4652
4745
|
fp.seek(0, 0)
|
|
4653
4746
|
if(prechck!="zstd"):
|
|
4654
4747
|
return UncompressFileAlt(fp, formatspecs)
|
|
4655
|
-
filefp =
|
|
4748
|
+
filefp = MkTempFile()
|
|
4656
4749
|
fp.seek(0, 0)
|
|
4657
4750
|
outstring = UncompressBytes(fp.read(), formatspecs)
|
|
4658
4751
|
filefp.write(outstring)
|
|
@@ -4669,7 +4762,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, compressi
|
|
|
4669
4762
|
if(compression not in compressionuselist and compression is None):
|
|
4670
4763
|
compression = "auto"
|
|
4671
4764
|
if(compression == "gzip" and compression in compressionsupport):
|
|
4672
|
-
bytesfp =
|
|
4765
|
+
bytesfp = MkTempFile()
|
|
4673
4766
|
if(compressionlevel is None):
|
|
4674
4767
|
compressionlevel = 9
|
|
4675
4768
|
else:
|
|
@@ -4677,7 +4770,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, compressi
|
|
|
4677
4770
|
bytesfp.write(GzipCompressData(
|
|
4678
4771
|
fp.read(), compresslevel=compressionlevel))
|
|
4679
4772
|
elif(compression == "bzip2" and compression in compressionsupport):
|
|
4680
|
-
bytesfp =
|
|
4773
|
+
bytesfp = MkTempFile()
|
|
4681
4774
|
if(compressionlevel is None):
|
|
4682
4775
|
compressionlevel = 9
|
|
4683
4776
|
else:
|
|
@@ -4685,7 +4778,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, compressi
|
|
|
4685
4778
|
bytesfp.write(BzipCompressData(
|
|
4686
4779
|
fp.read(), compresslevel=compressionlevel))
|
|
4687
4780
|
elif(compression == "lz4" and compression in compressionsupport):
|
|
4688
|
-
bytesfp =
|
|
4781
|
+
bytesfp = MkTempFile()
|
|
4689
4782
|
if(compressionlevel is None):
|
|
4690
4783
|
compressionlevel = 9
|
|
4691
4784
|
else:
|
|
@@ -4693,14 +4786,14 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, compressi
|
|
|
4693
4786
|
bytesfp.write(lz4.frame.compress(
|
|
4694
4787
|
fp.read(), compression_level=compressionlevel))
|
|
4695
4788
|
elif((compression == "lzo" or compression == "lzop") and compression in compressionsupport):
|
|
4696
|
-
bytesfp =
|
|
4789
|
+
bytesfp = MkTempFile()
|
|
4697
4790
|
if(compressionlevel is None):
|
|
4698
4791
|
compressionlevel = 9
|
|
4699
4792
|
else:
|
|
4700
4793
|
compressionlevel = int(compressionlevel)
|
|
4701
4794
|
bytesfp.write(lzo.compress(fp.read(), compressionlevel))
|
|
4702
4795
|
elif(compression == "zstd" and compression in compressionsupport):
|
|
4703
|
-
bytesfp =
|
|
4796
|
+
bytesfp = MkTempFile()
|
|
4704
4797
|
if(compressionlevel is None):
|
|
4705
4798
|
compressionlevel = 9
|
|
4706
4799
|
else:
|
|
@@ -4708,7 +4801,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, compressi
|
|
|
4708
4801
|
compressor = zstandard.ZstdCompressor(compressionlevel, threads=get_default_threads())
|
|
4709
4802
|
bytesfp.write(compressor.compress(fp.read()))
|
|
4710
4803
|
elif(compression == "lzma" and compression in compressionsupport):
|
|
4711
|
-
bytesfp =
|
|
4804
|
+
bytesfp = MkTempFile()
|
|
4712
4805
|
if(compressionlevel is None):
|
|
4713
4806
|
compressionlevel = 9
|
|
4714
4807
|
else:
|
|
@@ -4718,7 +4811,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, compressi
|
|
|
4718
4811
|
except (NotImplementedError, lzma.LZMAError):
|
|
4719
4812
|
bytesfp.write(lzma.compress(fp.read(), format=lzma.FORMAT_ALONE))
|
|
4720
4813
|
elif(compression == "xz" and compression in compressionsupport):
|
|
4721
|
-
bytesfp =
|
|
4814
|
+
bytesfp = MkTempFile()
|
|
4722
4815
|
if(compressionlevel is None):
|
|
4723
4816
|
compressionlevel = 9
|
|
4724
4817
|
else:
|
|
@@ -4728,7 +4821,7 @@ def CompressOpenFileAlt(fp, compression="auto", compressionlevel=None, compressi
|
|
|
4728
4821
|
except (NotImplementedError, lzma.LZMAError):
|
|
4729
4822
|
bytesfp.write(lzma.compress(fp.read(), format=lzma.FORMAT_XZ))
|
|
4730
4823
|
elif(compression == "zlib" and compression in compressionsupport):
|
|
4731
|
-
bytesfp =
|
|
4824
|
+
bytesfp = MkTempFile()
|
|
4732
4825
|
if(compressionlevel is None):
|
|
4733
4826
|
compressionlevel = 9
|
|
4734
4827
|
else:
|
|
@@ -4898,11 +4991,11 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
|
|
|
4898
4991
|
pass
|
|
4899
4992
|
if(outfile == "-" or outfile is None):
|
|
4900
4993
|
verbose = False
|
|
4901
|
-
fp =
|
|
4994
|
+
fp = MkTempFile()
|
|
4902
4995
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
4903
4996
|
fp = outfile
|
|
4904
4997
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
4905
|
-
fp =
|
|
4998
|
+
fp = MkTempFile()
|
|
4906
4999
|
else:
|
|
4907
5000
|
fbasename = os.path.splitext(outfile)[0]
|
|
4908
5001
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -5097,7 +5190,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
|
|
|
5097
5190
|
fwinattributes = format(int(0), 'x').lower()
|
|
5098
5191
|
fcompression = ""
|
|
5099
5192
|
fcsize = format(int(0), 'x').lower()
|
|
5100
|
-
fcontents =
|
|
5193
|
+
fcontents = MkTempFile()
|
|
5101
5194
|
fcencoding = "UTF-8"
|
|
5102
5195
|
curcompression = "none"
|
|
5103
5196
|
if not followlink and ftype in data_types:
|
|
@@ -5115,7 +5208,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
|
|
|
5115
5208
|
ilmin = 0
|
|
5116
5209
|
ilcsize = []
|
|
5117
5210
|
while(ilmin < ilsize):
|
|
5118
|
-
cfcontents =
|
|
5211
|
+
cfcontents = MkTempFile()
|
|
5119
5212
|
fcontents.seek(0, 0)
|
|
5120
5213
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5121
5214
|
fcontents.seek(0, 0)
|
|
@@ -5132,7 +5225,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
|
|
|
5132
5225
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
5133
5226
|
curcompression = compressionuselist[ilcmin]
|
|
5134
5227
|
fcontents.seek(0, 0)
|
|
5135
|
-
cfcontents =
|
|
5228
|
+
cfcontents = MkTempFile()
|
|
5136
5229
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5137
5230
|
cfcontents.seek(0, 0)
|
|
5138
5231
|
cfcontents = CompressOpenFileAlt(
|
|
@@ -5162,7 +5255,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
|
|
|
5162
5255
|
ilmin = 0
|
|
5163
5256
|
ilcsize = []
|
|
5164
5257
|
while(ilmin < ilsize):
|
|
5165
|
-
cfcontents =
|
|
5258
|
+
cfcontents = MkTempFile()
|
|
5166
5259
|
fcontents.seek(0, 0)
|
|
5167
5260
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5168
5261
|
fcontents.seek(0, 0)
|
|
@@ -5179,7 +5272,7 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, fmttype="auto", comp
|
|
|
5179
5272
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
5180
5273
|
curcompression = compressionuselist[ilcmin]
|
|
5181
5274
|
fcontents.seek(0, 0)
|
|
5182
|
-
cfcontents =
|
|
5275
|
+
cfcontents = MkTempFile()
|
|
5183
5276
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5184
5277
|
cfcontents.seek(0, 0)
|
|
5185
5278
|
cfcontents = CompressOpenFileAlt(
|
|
@@ -5282,11 +5375,11 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5282
5375
|
pass
|
|
5283
5376
|
if(outfile == "-" or outfile is None):
|
|
5284
5377
|
verbose = False
|
|
5285
|
-
fp =
|
|
5378
|
+
fp = MkTempFile()
|
|
5286
5379
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5287
5380
|
fp = outfile
|
|
5288
5381
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
5289
|
-
fp =
|
|
5382
|
+
fp = MkTempFile()
|
|
5290
5383
|
else:
|
|
5291
5384
|
fbasename = os.path.splitext(outfile)[0]
|
|
5292
5385
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -5305,7 +5398,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5305
5398
|
filetoinode = {}
|
|
5306
5399
|
inodetoforminode = {}
|
|
5307
5400
|
if(infile == "-"):
|
|
5308
|
-
infile =
|
|
5401
|
+
infile = MkTempFile()
|
|
5309
5402
|
if(hasattr(sys.stdin, "buffer")):
|
|
5310
5403
|
shutil.copyfileobj(sys.stdin.buffer, infile)
|
|
5311
5404
|
else:
|
|
@@ -5444,7 +5537,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5444
5537
|
fwinattributes = format(int(0), 'x').lower()
|
|
5445
5538
|
fcompression = ""
|
|
5446
5539
|
fcsize = format(int(0), 'x').lower()
|
|
5447
|
-
fcontents =
|
|
5540
|
+
fcontents = MkTempFile()
|
|
5448
5541
|
fcencoding = "UTF-8"
|
|
5449
5542
|
curcompression = "none"
|
|
5450
5543
|
if ftype in data_types:
|
|
@@ -5463,7 +5556,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5463
5556
|
ilmin = 0
|
|
5464
5557
|
ilcsize = []
|
|
5465
5558
|
while(ilmin < ilsize):
|
|
5466
|
-
cfcontents =
|
|
5559
|
+
cfcontents = MkTempFile()
|
|
5467
5560
|
fcontents.seek(0, 0)
|
|
5468
5561
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5469
5562
|
fcontents.seek(0, 0)
|
|
@@ -5480,7 +5573,7 @@ def PackArchiveFileFromTarFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5480
5573
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
5481
5574
|
curcompression = compressionuselist[ilcmin]
|
|
5482
5575
|
fcontents.seek(0, 0)
|
|
5483
|
-
cfcontents =
|
|
5576
|
+
cfcontents = MkTempFile()
|
|
5484
5577
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5485
5578
|
cfcontents.seek(0, 0)
|
|
5486
5579
|
cfcontents = CompressOpenFileAlt(
|
|
@@ -5579,11 +5672,11 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5579
5672
|
pass
|
|
5580
5673
|
if(outfile == "-" or outfile is None):
|
|
5581
5674
|
verbose = False
|
|
5582
|
-
fp =
|
|
5675
|
+
fp = MkTempFile()
|
|
5583
5676
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5584
5677
|
fp = outfile
|
|
5585
5678
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
5586
|
-
fp =
|
|
5679
|
+
fp = MkTempFile()
|
|
5587
5680
|
else:
|
|
5588
5681
|
fbasename = os.path.splitext(outfile)[0]
|
|
5589
5682
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -5602,7 +5695,7 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5602
5695
|
filetoinode = {}
|
|
5603
5696
|
inodetoforminode = {}
|
|
5604
5697
|
if(infile == "-"):
|
|
5605
|
-
infile =
|
|
5698
|
+
infile = MkTempFile()
|
|
5606
5699
|
if(hasattr(sys.stdin, "buffer")):
|
|
5607
5700
|
shutil.copyfileobj(sys.stdin.buffer, infile)
|
|
5608
5701
|
else:
|
|
@@ -5743,7 +5836,7 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5743
5836
|
fgname = ""
|
|
5744
5837
|
except ImportError:
|
|
5745
5838
|
fgname = ""
|
|
5746
|
-
fcontents =
|
|
5839
|
+
fcontents = MkTempFile()
|
|
5747
5840
|
fcencoding = "UTF-8"
|
|
5748
5841
|
curcompression = "none"
|
|
5749
5842
|
if ftype == 0:
|
|
@@ -5760,7 +5853,7 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5760
5853
|
ilmin = 0
|
|
5761
5854
|
ilcsize = []
|
|
5762
5855
|
while(ilmin < ilsize):
|
|
5763
|
-
cfcontents =
|
|
5856
|
+
cfcontents = MkTempFile()
|
|
5764
5857
|
fcontents.seek(0, 0)
|
|
5765
5858
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5766
5859
|
fcontents.seek(0, 0)
|
|
@@ -5774,7 +5867,7 @@ def PackArchiveFileFromZipFile(infile, outfile, fmttype="auto", compression="aut
|
|
|
5774
5867
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
5775
5868
|
curcompression = compressionuselist[ilcmin]
|
|
5776
5869
|
fcontents.seek(0, 0)
|
|
5777
|
-
cfcontents =
|
|
5870
|
+
cfcontents = MkTempFile()
|
|
5778
5871
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
5779
5872
|
cfcontents.seek(0, 0)
|
|
5780
5873
|
cfcontents = CompressOpenFileAlt(
|
|
@@ -5878,11 +5971,11 @@ if(rarfile_support):
|
|
|
5878
5971
|
pass
|
|
5879
5972
|
if(outfile == "-" or outfile is None):
|
|
5880
5973
|
verbose = False
|
|
5881
|
-
fp =
|
|
5974
|
+
fp = MkTempFile()
|
|
5882
5975
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
5883
5976
|
fp = outfile
|
|
5884
5977
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
5885
|
-
fp =
|
|
5978
|
+
fp = MkTempFile()
|
|
5886
5979
|
else:
|
|
5887
5980
|
fbasename = os.path.splitext(outfile)[0]
|
|
5888
5981
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -6060,7 +6153,7 @@ if(rarfile_support):
|
|
|
6060
6153
|
fgname = ""
|
|
6061
6154
|
except ImportError:
|
|
6062
6155
|
fgname = ""
|
|
6063
|
-
fcontents =
|
|
6156
|
+
fcontents = MkTempFile()
|
|
6064
6157
|
fcencoding = "UTF-8"
|
|
6065
6158
|
curcompression = "none"
|
|
6066
6159
|
if ftype == 0:
|
|
@@ -6077,7 +6170,7 @@ if(rarfile_support):
|
|
|
6077
6170
|
ilmin = 0
|
|
6078
6171
|
ilcsize = []
|
|
6079
6172
|
while(ilmin < ilsize):
|
|
6080
|
-
cfcontents =
|
|
6173
|
+
cfcontents = MkTempFile()
|
|
6081
6174
|
fcontents.seek(0, 0)
|
|
6082
6175
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
6083
6176
|
fcontents.seek(0, 0)
|
|
@@ -6094,7 +6187,7 @@ if(rarfile_support):
|
|
|
6094
6187
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
6095
6188
|
curcompression = compressionuselist[ilcmin]
|
|
6096
6189
|
fcontents.seek(0, 0)
|
|
6097
|
-
cfcontents =
|
|
6190
|
+
cfcontents = MkTempFile()
|
|
6098
6191
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
6099
6192
|
cfcontents.seek(0, 0)
|
|
6100
6193
|
cfcontents = CompressOpenFileAlt(
|
|
@@ -6198,11 +6291,11 @@ if(py7zr_support):
|
|
|
6198
6291
|
pass
|
|
6199
6292
|
if(outfile == "-" or outfile is None):
|
|
6200
6293
|
verbose = False
|
|
6201
|
-
fp =
|
|
6294
|
+
fp = MkTempFile()
|
|
6202
6295
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
6203
6296
|
fp = outfile
|
|
6204
6297
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
6205
|
-
fp =
|
|
6298
|
+
fp = MkTempFile()
|
|
6206
6299
|
else:
|
|
6207
6300
|
fbasename = os.path.splitext(outfile)[0]
|
|
6208
6301
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -6311,7 +6404,7 @@ if(py7zr_support):
|
|
|
6311
6404
|
fgname = ""
|
|
6312
6405
|
except ImportError:
|
|
6313
6406
|
fgname = ""
|
|
6314
|
-
fcontents =
|
|
6407
|
+
fcontents = MkTempFile()
|
|
6315
6408
|
fcencoding = "UTF-8"
|
|
6316
6409
|
curcompression = "none"
|
|
6317
6410
|
if ftype == 0:
|
|
@@ -6331,7 +6424,7 @@ if(py7zr_support):
|
|
|
6331
6424
|
ilmin = 0
|
|
6332
6425
|
ilcsize = []
|
|
6333
6426
|
while(ilmin < ilsize):
|
|
6334
|
-
cfcontents =
|
|
6427
|
+
cfcontents = MkTempFile()
|
|
6335
6428
|
fcontents.seek(0, 0)
|
|
6336
6429
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
6337
6430
|
fcontents.seek(0, 0)
|
|
@@ -6348,7 +6441,7 @@ if(py7zr_support):
|
|
|
6348
6441
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
6349
6442
|
curcompression = compressionuselist[ilcmin]
|
|
6350
6443
|
fcontents.seek(0, 0)
|
|
6351
|
-
cfcontents =
|
|
6444
|
+
cfcontents = MkTempFile()
|
|
6352
6445
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
6353
6446
|
cfcontents.seek(0, 0)
|
|
6354
6447
|
cfcontents = CompressOpenFileAlt(
|
|
@@ -6463,7 +6556,7 @@ def ArchiveFileSeekToFileNum(infile, fmttype="auto", seekto=0, listonly=False, c
|
|
|
6463
6556
|
return False
|
|
6464
6557
|
fp.seek(0, 0)
|
|
6465
6558
|
elif(infile == "-"):
|
|
6466
|
-
fp =
|
|
6559
|
+
fp = MkTempFile()
|
|
6467
6560
|
if(hasattr(sys.stdin, "buffer")):
|
|
6468
6561
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
6469
6562
|
else:
|
|
@@ -6477,7 +6570,7 @@ def ArchiveFileSeekToFileNum(infile, fmttype="auto", seekto=0, listonly=False, c
|
|
|
6477
6570
|
return False
|
|
6478
6571
|
fp.seek(0, 0)
|
|
6479
6572
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
6480
|
-
fp =
|
|
6573
|
+
fp = MkTempFile()
|
|
6481
6574
|
fp.write(infile)
|
|
6482
6575
|
fp.seek(0, 0)
|
|
6483
6576
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -6778,7 +6871,7 @@ def ArchiveFileSeekToFileName(infile, fmttype="auto", seekfile=None, listonly=Fa
|
|
|
6778
6871
|
return False
|
|
6779
6872
|
fp.seek(0, 0)
|
|
6780
6873
|
elif(infile == "-"):
|
|
6781
|
-
fp =
|
|
6874
|
+
fp = MkTempFile()
|
|
6782
6875
|
if(hasattr(sys.stdin, "buffer")):
|
|
6783
6876
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
6784
6877
|
else:
|
|
@@ -6792,7 +6885,7 @@ def ArchiveFileSeekToFileName(infile, fmttype="auto", seekfile=None, listonly=Fa
|
|
|
6792
6885
|
return False
|
|
6793
6886
|
fp.seek(0, 0)
|
|
6794
6887
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
6795
|
-
fp =
|
|
6888
|
+
fp = MkTempFile()
|
|
6796
6889
|
fp.write(infile)
|
|
6797
6890
|
fp.seek(0, 0)
|
|
6798
6891
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -7099,7 +7192,7 @@ def ArchiveFileValidate(infile, fmttype="auto", formatspecs=__file_format_multi_
|
|
|
7099
7192
|
return False
|
|
7100
7193
|
fp.seek(0, 0)
|
|
7101
7194
|
elif(infile == "-"):
|
|
7102
|
-
fp =
|
|
7195
|
+
fp = MkTempFile()
|
|
7103
7196
|
if(hasattr(sys.stdin, "buffer")):
|
|
7104
7197
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
7105
7198
|
else:
|
|
@@ -7113,7 +7206,7 @@ def ArchiveFileValidate(infile, fmttype="auto", formatspecs=__file_format_multi_
|
|
|
7113
7206
|
return False
|
|
7114
7207
|
fp.seek(0, 0)
|
|
7115
7208
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
7116
|
-
fp =
|
|
7209
|
+
fp = MkTempFile()
|
|
7117
7210
|
fp.write(infile)
|
|
7118
7211
|
fp.seek(0, 0)
|
|
7119
7212
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -7451,7 +7544,7 @@ def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=
|
|
|
7451
7544
|
return False
|
|
7452
7545
|
fp.seek(0, 0)
|
|
7453
7546
|
elif(infile == "-"):
|
|
7454
|
-
fp =
|
|
7547
|
+
fp = MkTempFile()
|
|
7455
7548
|
if(hasattr(sys.stdin, "buffer")):
|
|
7456
7549
|
shutil.copyfileobj(sys.stdin.buffer, fp)
|
|
7457
7550
|
else:
|
|
@@ -7465,7 +7558,7 @@ def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=
|
|
|
7465
7558
|
return False
|
|
7466
7559
|
fp.seek(0, 0)
|
|
7467
7560
|
elif(isinstance(infile, bytes) and sys.version_info[0] >= 3):
|
|
7468
|
-
fp =
|
|
7561
|
+
fp = MkTempFile()
|
|
7469
7562
|
fp.write(infile)
|
|
7470
7563
|
fp.seek(0, 0)
|
|
7471
7564
|
fp = UncompressFileAlt(fp, formatspecs)
|
|
@@ -7765,7 +7858,7 @@ def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=
|
|
|
7765
7858
|
outfjsoncontent = {}
|
|
7766
7859
|
elif(outfjsontype=="list"):
|
|
7767
7860
|
outfprejsoncontent = fp.read(outfjsonsize).decode("UTF-8")
|
|
7768
|
-
flisttmp =
|
|
7861
|
+
flisttmp = MkTempFile()
|
|
7769
7862
|
flisttmp.write(outfprejsoncontent.encode())
|
|
7770
7863
|
flisttmp.seek(0)
|
|
7771
7864
|
outfjsoncontent = ReadFileHeaderData(flisttmp, outfjsonlen, formatspecs['format_delimiter'])
|
|
@@ -7818,7 +7911,7 @@ def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=
|
|
|
7818
7911
|
VerbosePrintOut("'" + outfjsonchecksum + "' != " + "'" + injsonfcs + "'")
|
|
7819
7912
|
return False
|
|
7820
7913
|
outfcontentstart = fp.tell()
|
|
7821
|
-
outfcontents =
|
|
7914
|
+
outfcontents = MkTempFile()
|
|
7822
7915
|
pyhascontents = False
|
|
7823
7916
|
if(outfsize > 0 and not listonly):
|
|
7824
7917
|
if(outfcompression == "none" or outfcompression == "" or outfcompression == "auto"):
|
|
@@ -7843,7 +7936,7 @@ def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=
|
|
|
7843
7936
|
cfcontents = UncompressFileAlt(
|
|
7844
7937
|
outfcontents, formatspecs)
|
|
7845
7938
|
cfcontents.seek(0, 0)
|
|
7846
|
-
outfcontents =
|
|
7939
|
+
outfcontents = MkTempFile()
|
|
7847
7940
|
shutil.copyfileobj(cfcontents, outfcontents)
|
|
7848
7941
|
cfcontents.close()
|
|
7849
7942
|
outfcontents.seek(0, 0)
|
|
@@ -7904,7 +7997,7 @@ def ArchiveFileStringToArray(instr, seekstart=0, seekend=0, listonly=False, cont
|
|
|
7904
7997
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7905
7998
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7906
7999
|
formatspecs = formatspecs[checkcompressfile]
|
|
7907
|
-
fp =
|
|
8000
|
+
fp = MkTempFile(instr)
|
|
7908
8001
|
listarchivefiles = ArchiveFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
7909
8002
|
return listarchivefiles
|
|
7910
8003
|
|
|
@@ -7913,7 +8006,7 @@ def TarFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentasfile
|
|
|
7913
8006
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7914
8007
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7915
8008
|
formatspecs = formatspecs[checkcompressfile]
|
|
7916
|
-
fp =
|
|
8009
|
+
fp = MkTempFile()
|
|
7917
8010
|
fp = PackArchiveFileFromTarFile(
|
|
7918
8011
|
infile, fp, "auto", True, None, compressionlistalt, "crc32", [], formatspecs, False, True)
|
|
7919
8012
|
listarchivefiles = ArchiveFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
@@ -7924,7 +8017,7 @@ def ZipFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentasfile
|
|
|
7924
8017
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7925
8018
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7926
8019
|
formatspecs = formatspecs[checkcompressfile]
|
|
7927
|
-
fp =
|
|
8020
|
+
fp = MkTempFile()
|
|
7928
8021
|
fp = PackArchiveFileFromZipFile(
|
|
7929
8022
|
infile, fp, "auto", True, None, compressionlistalt, "crc32", [], formatspecs, False, True)
|
|
7930
8023
|
listarchivefiles = ArchiveFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
@@ -7940,7 +8033,7 @@ if(rarfile_support):
|
|
|
7940
8033
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7941
8034
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7942
8035
|
formatspecs = formatspecs[checkcompressfile]
|
|
7943
|
-
fp =
|
|
8036
|
+
fp = MkTempFile()
|
|
7944
8037
|
fp = PackArchiveFileFromRarFile(
|
|
7945
8038
|
infile, fp, "auto", True, None, compressionlistalt, "crc32", [], formatspecs, False, True)
|
|
7946
8039
|
listarchivefiles = ArchiveFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
@@ -7955,7 +8048,7 @@ if(py7zr_support):
|
|
|
7955
8048
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, True)
|
|
7956
8049
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
7957
8050
|
formatspecs = formatspecs[checkcompressfile]
|
|
7958
|
-
fp =
|
|
8051
|
+
fp = MkTempFile()
|
|
7959
8052
|
fp = PackArchiveFileFromSevenZipFile(
|
|
7960
8053
|
infile, fp, "auto", True, None, compressionlistalt, "crc32", [], formatspecs, False, True)
|
|
7961
8054
|
listarchivefiles = ArchiveFileToArray(fp, "auto", seekstart, seekend, listonly, contentasfile, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
@@ -7982,7 +8075,7 @@ def InFileToArray(infile, seekstart=0, seekend=0, listonly=False, contentasfile=
|
|
|
7982
8075
|
|
|
7983
8076
|
|
|
7984
8077
|
def ListDirToArray(infiles, dirlistfromtxt=False, fmttype=__file_format_default__, compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, seekstart=0, seekend=0, listonly=False, skipchecksum=False, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_dict__, verbose=False, seektoend=False, returnfp=False):
|
|
7985
|
-
outarray =
|
|
8078
|
+
outarray = MkTempFile()
|
|
7986
8079
|
packform = PackArchiveFile(infiles, outarray, dirlistfromtxt, fmttype, compression, compresswholefile,
|
|
7987
8080
|
compressionlevel, followlink, checksumtype, extradata, formatspecs, verbose, True)
|
|
7988
8081
|
listarchivefiles = ArchiveFileToArray(outarray, "auto", seekstart, seekend, listonly, True, skipchecksum, formatspecs, seektoend, returnfp)
|
|
@@ -8091,11 +8184,11 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
|
|
|
8091
8184
|
return False
|
|
8092
8185
|
if(outfile == "-" or outfile is None):
|
|
8093
8186
|
verbose = False
|
|
8094
|
-
fp =
|
|
8187
|
+
fp = MkTempFile()
|
|
8095
8188
|
elif(hasattr(outfile, "read") or hasattr(outfile, "write")):
|
|
8096
8189
|
fp = outfile
|
|
8097
8190
|
elif(re.findall("^(ftp|ftps|sftp):\\/\\/", outfile)):
|
|
8098
|
-
fp =
|
|
8191
|
+
fp = MkTempFile()
|
|
8099
8192
|
else:
|
|
8100
8193
|
fbasename = os.path.splitext(outfile)[0]
|
|
8101
8194
|
fextname = os.path.splitext(outfile)[1]
|
|
@@ -8183,7 +8276,7 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
|
|
|
8183
8276
|
jsondata = listarchivefiles['ffilelist'][reallcfi]['fjsondata']
|
|
8184
8277
|
fcontents = listarchivefiles['ffilelist'][reallcfi]['fcontents']
|
|
8185
8278
|
if(not listarchivefiles['ffilelist'][reallcfi]['fcontentasfile']):
|
|
8186
|
-
fcontents =
|
|
8279
|
+
fcontents = MkTempFile(fcontents)
|
|
8187
8280
|
typechecktest = CheckCompressionType(fcontents, closefp=False)
|
|
8188
8281
|
fcontents.seek(0, 0)
|
|
8189
8282
|
fcencoding = GetFileEncoding(fcontents, False)
|
|
@@ -8199,7 +8292,7 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
|
|
|
8199
8292
|
ilmin = 0
|
|
8200
8293
|
ilcsize = []
|
|
8201
8294
|
while(ilmin < ilsize):
|
|
8202
|
-
cfcontents =
|
|
8295
|
+
cfcontents = MkTempFile()
|
|
8203
8296
|
fcontents.seek(0, 0)
|
|
8204
8297
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
8205
8298
|
fcontents.seek(0, 0)
|
|
@@ -8216,7 +8309,7 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
|
|
|
8216
8309
|
ilcmin = ilcsize.index(min(ilcsize))
|
|
8217
8310
|
curcompression = compressionuselist[ilcmin]
|
|
8218
8311
|
fcontents.seek(0, 0)
|
|
8219
|
-
cfcontents =
|
|
8312
|
+
cfcontents = MkTempFile()
|
|
8220
8313
|
shutil.copyfileobj(fcontents, cfcontents)
|
|
8221
8314
|
cfcontents.seek(0, 0)
|
|
8222
8315
|
cfcontents = CompressOpenFileAlt(
|
|
@@ -8265,7 +8358,7 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
|
|
|
8265
8358
|
extradata = flinkinfo['fjsondata']
|
|
8266
8359
|
fcontents = flinkinfo['fcontents']
|
|
8267
8360
|
if(not flinkinfo['fcontentasfile']):
|
|
8268
|
-
fcontents =
|
|
8361
|
+
fcontents = MkTempFile(fcontents)
|
|
8269
8362
|
ftypehex = format(flinkinfo['ftype'], 'x').lower()
|
|
8270
8363
|
else:
|
|
8271
8364
|
ftypehex = format(
|
|
@@ -8336,14 +8429,14 @@ def RePackArchiveFile(infile, outfile, fmttype="auto", compression="auto", compr
|
|
|
8336
8429
|
|
|
8337
8430
|
|
|
8338
8431
|
def RePackArchiveFileFromString(instr, outfile, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, checksumtype=["crc32", "crc32", "crc32"], skipchecksum=False, extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
8339
|
-
fp =
|
|
8432
|
+
fp = MkTempFile(instr)
|
|
8340
8433
|
listarchivefiles = RePackArchiveFile(fp, outfile, fmttype, compression, compresswholefile, compressionlevel, compressionuselist,
|
|
8341
8434
|
checksumtype, skipchecksum, extradata, formatspecs, verbose, returnfp)
|
|
8342
8435
|
return listarchivefiles
|
|
8343
8436
|
|
|
8344
8437
|
|
|
8345
8438
|
def PackArchiveFileFromListDir(infiles, outfile, dirlistfromtxt=False, fmttype="auto", compression="auto", compresswholefile=True, compressionlevel=None, compressionuselist=compressionlistalt, followlink=False, skipchecksum=False, checksumtype=["crc32", "crc32", "crc32"], extradata=[], formatspecs=__file_format_dict__, verbose=False, returnfp=False):
|
|
8346
|
-
outarray =
|
|
8439
|
+
outarray = MkTempFile()
|
|
8347
8440
|
packform = PackArchiveFile(infiles, outarray, dirlistfromtxt, fmttype, compression, compresswholefile,
|
|
8348
8441
|
compressionlevel, compressionuselist, followlink, checksumtype, extradata, formatspecs, verbose, True)
|
|
8349
8442
|
listarchivefiles = RePackArchiveFile(outarray, outfile, fmttype, compression, compresswholefile,
|
|
@@ -8401,7 +8494,7 @@ def UnPackArchiveFile(infile, outdir=None, followlink=False, seekstart=0, seeken
|
|
|
8401
8494
|
if(listarchivefiles['ffilelist'][lcfi]['ftype'] == 0 or listarchivefiles['ffilelist'][lcfi]['ftype'] == 7):
|
|
8402
8495
|
with open(PrependPath(outdir, listarchivefiles['ffilelist'][lcfi]['fname']), "wb") as fpc:
|
|
8403
8496
|
if(not listarchivefiles['ffilelist'][lcfi]['fcontentasfile']):
|
|
8404
|
-
listarchivefiles['ffilelist'][lcfi]['fcontents'] =
|
|
8497
|
+
listarchivefiles['ffilelist'][lcfi]['fcontents'] = MkTempFile(
|
|
8405
8498
|
listarchivefiles['ffilelist'][lcfi]['fcontents'])
|
|
8406
8499
|
listarchivefiles['ffilelist'][lcfi]['fcontents'].seek(0, 0)
|
|
8407
8500
|
shutil.copyfileobj(
|
|
@@ -8453,7 +8546,7 @@ def UnPackArchiveFile(infile, outdir=None, followlink=False, seekstart=0, seeken
|
|
|
8453
8546
|
if(flinkinfo['ftype'] == 0 or flinkinfo['ftype'] == 7):
|
|
8454
8547
|
with open(PrependPath(outdir, listarchivefiles['ffilelist'][lcfi]['fname']), "wb") as fpc:
|
|
8455
8548
|
if(not flinkinfo['fcontentasfile']):
|
|
8456
|
-
flinkinfo['fcontents'] =
|
|
8549
|
+
flinkinfo['fcontents'] = MkTempFile(
|
|
8457
8550
|
flinkinfo['fcontents'])
|
|
8458
8551
|
flinkinfo['fcontents'].seek(0, 0)
|
|
8459
8552
|
shutil.copyfileobj(flinkinfo['fcontents'], fpc)
|
|
@@ -8532,7 +8625,7 @@ def UnPackArchiveFile(infile, outdir=None, followlink=False, seekstart=0, seeken
|
|
|
8532
8625
|
if(flinkinfo['ftype'] == 0 or flinkinfo['ftype'] == 7):
|
|
8533
8626
|
with open(PrependPath(outdir, listarchivefiles['ffilelist'][lcfi]['fname']), "wb") as fpc:
|
|
8534
8627
|
if(not flinkinfo['fcontentasfile']):
|
|
8535
|
-
flinkinfo['fcontents'] =
|
|
8628
|
+
flinkinfo['fcontents'] = MkTempFile(
|
|
8536
8629
|
flinkinfo['fcontents'])
|
|
8537
8630
|
flinkinfo['fcontents'].seek(0, 0)
|
|
8538
8631
|
shutil.copyfileobj(flinkinfo['fcontents'], fpc)
|
|
@@ -8610,7 +8703,7 @@ def UnPackArchiveFile(infile, outdir=None, followlink=False, seekstart=0, seeken
|
|
|
8610
8703
|
|
|
8611
8704
|
|
|
8612
8705
|
def UnPackArchiveFileString(instr, outdir=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False, verbose=False, returnfp=False):
|
|
8613
|
-
fp =
|
|
8706
|
+
fp = MkTempFile(instr)
|
|
8614
8707
|
listarchivefiles = UnPackArchiveFile(fp, outdir, followlink, seekstart, seekend, skipchecksum, formatspecs, seektoend, verbose, returnfp)
|
|
8615
8708
|
return listarchivefiles
|
|
8616
8709
|
|
|
@@ -8683,7 +8776,7 @@ def ArchiveFileListFiles(infile, fmttype="auto", seekstart=0, seekend=0, skipche
|
|
|
8683
8776
|
|
|
8684
8777
|
|
|
8685
8778
|
def ArchiveFileStringListFiles(instr, seekstart=0, seekend=0, skipchecksum=False, formatspecs=__file_format_multi_dict__, seektoend=False, verbose=False, newstyle=False, returnfp=False):
|
|
8686
|
-
fp =
|
|
8779
|
+
fp = MkTempFile(instr)
|
|
8687
8780
|
listarchivefiles = ArchiveFileListFiles(
|
|
8688
8781
|
instr, seekstart, seekend, skipchecksum, formatspecs, seektoend, verbose, newstyle, returnfp)
|
|
8689
8782
|
return listarchivefiles
|
|
@@ -8693,7 +8786,7 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
8693
8786
|
if(verbose):
|
|
8694
8787
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
8695
8788
|
if(infile == "-"):
|
|
8696
|
-
infile =
|
|
8789
|
+
infile = MkTempFile()
|
|
8697
8790
|
if(hasattr(sys.stdin, "buffer")):
|
|
8698
8791
|
shutil.copyfileobj(sys.stdin.buffer, infile)
|
|
8699
8792
|
else:
|
|
@@ -8818,7 +8911,7 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
8818
8911
|
if(verbose):
|
|
8819
8912
|
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG)
|
|
8820
8913
|
if(infile == "-"):
|
|
8821
|
-
infile =
|
|
8914
|
+
infile = MkTempFile()
|
|
8822
8915
|
if(hasattr(sys.stdin, "buffer")):
|
|
8823
8916
|
shutil.copyfileobj(sys.stdin.buffer, infile)
|
|
8824
8917
|
else:
|
|
@@ -9214,7 +9307,7 @@ def InFileListFiles(infile, verbose=False, formatspecs=__file_format_multi_dict_
|
|
|
9214
9307
|
|
|
9215
9308
|
|
|
9216
9309
|
def ListDirListFiles(infiles, dirlistfromtxt=False, compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, checksumtype=["crc32", "crc32", "crc32"], formatspecs=__file_format_dict__, seektoend=False, verbose=False, returnfp=False):
|
|
9217
|
-
outarray =
|
|
9310
|
+
outarray = MkTempFile()
|
|
9218
9311
|
packform = PackArchiveFile(infiles, outarray, dirlistfromtxt, compression, compresswholefile,
|
|
9219
9312
|
compressionlevel, followlink, checksumtype, formatspecs, False, True)
|
|
9220
9313
|
listarchivefiles = ArchiveFileListFiles(
|
|
@@ -9232,7 +9325,7 @@ def make_empty_archive_file_pointer_neo(fp, fmttype=None, checksumtype='crc32',
|
|
|
9232
9325
|
return make_empty_file_pointer_neo(fp, fmttype, checksumtype, formatspecs, encoding)
|
|
9233
9326
|
|
|
9234
9327
|
def make_empty_file_neo(outfile=None, fmttype=None, checksumtype='crc32', formatspecs=__file_format_multi_dict__, encoding='UTF-8', returnfp=False):
|
|
9235
|
-
return MakeEmptyFile(outfile, fmttype, "auto", False, None, checksumtype, formatspecs, returnfp)
|
|
9328
|
+
return MakeEmptyFile(outfile, fmttype, "auto", False, None, compressionlistalt, checksumtype, formatspecs, returnfp)
|
|
9236
9329
|
|
|
9237
9330
|
def make_empty_archive_file_neo(outfile=None, fmttype=None, checksumtype='crc32', formatspecs=__file_format_multi_dict__, encoding='UTF-8', returnfp=False):
|
|
9238
9331
|
return make_empty_file_neo(outfile, fmttype, checksumtype, formatspecs, encoding, returnfp)
|
|
@@ -9300,7 +9393,7 @@ def download_file_from_ftp_file(url):
|
|
|
9300
9393
|
ftp.login(urlparts.username, urlparts.password)
|
|
9301
9394
|
if(urlparts.scheme == "ftps"):
|
|
9302
9395
|
ftp.prot_p()
|
|
9303
|
-
ftpfile =
|
|
9396
|
+
ftpfile = MkTempFile()
|
|
9304
9397
|
ftp.retrbinary("RETR "+urlparts.path, ftpfile.write)
|
|
9305
9398
|
#ftp.storbinary("STOR "+urlparts.path, ftpfile.write);
|
|
9306
9399
|
ftp.close()
|
|
@@ -9361,7 +9454,7 @@ def upload_file_to_ftp_file(ftpfile, url):
|
|
|
9361
9454
|
|
|
9362
9455
|
|
|
9363
9456
|
def upload_file_to_ftp_string(ftpstring, url):
|
|
9364
|
-
ftpfileo =
|
|
9457
|
+
ftpfileo = MkTempFile(ftpstring)
|
|
9365
9458
|
ftpfile = upload_file_to_ftp_file(ftpfileo, url)
|
|
9366
9459
|
ftpfileo.close()
|
|
9367
9460
|
return ftpfile
|
|
@@ -9413,7 +9506,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
|
|
|
9413
9506
|
return download_file_from_ftp_file(url)
|
|
9414
9507
|
|
|
9415
9508
|
# Create a temporary file object
|
|
9416
|
-
httpfile =
|
|
9509
|
+
httpfile = MkTempFile()
|
|
9417
9510
|
|
|
9418
9511
|
# 1) Requests branch
|
|
9419
9512
|
if usehttp == 'requests' and haverequests:
|
|
@@ -9521,7 +9614,7 @@ if(haveparamiko):
|
|
|
9521
9614
|
log.info("Error With URL "+url)
|
|
9522
9615
|
return False
|
|
9523
9616
|
sftp = ssh.open_sftp()
|
|
9524
|
-
sftpfile =
|
|
9617
|
+
sftpfile = MkTempFile()
|
|
9525
9618
|
sftp.getfo(urlparts.path, sftpfile)
|
|
9526
9619
|
sftp.close()
|
|
9527
9620
|
ssh.close()
|
|
@@ -9591,7 +9684,7 @@ else:
|
|
|
9591
9684
|
|
|
9592
9685
|
if(haveparamiko):
|
|
9593
9686
|
def upload_file_to_sftp_string(sftpstring, url):
|
|
9594
|
-
sftpfileo =
|
|
9687
|
+
sftpfileo = MkTempFile(sftpstring)
|
|
9595
9688
|
sftpfile = upload_file_to_sftp_files(sftpfileo, url)
|
|
9596
9689
|
sftpfileo.close()
|
|
9597
9690
|
return sftpfile
|
|
@@ -9637,7 +9730,7 @@ if(havepysftp):
|
|
|
9637
9730
|
log.info("Error With URL "+url)
|
|
9638
9731
|
return False
|
|
9639
9732
|
sftp = ssh.open_sftp()
|
|
9640
|
-
sftpfile =
|
|
9733
|
+
sftpfile = MkTempFile()
|
|
9641
9734
|
sftp.getfo(urlparts.path, sftpfile)
|
|
9642
9735
|
sftp.close()
|
|
9643
9736
|
ssh.close()
|
|
@@ -9704,7 +9797,7 @@ else:
|
|
|
9704
9797
|
|
|
9705
9798
|
if(havepysftp):
|
|
9706
9799
|
def upload_file_to_pysftp_string(sftpstring, url):
|
|
9707
|
-
sftpfileo =
|
|
9800
|
+
sftpfileo = MkTempFile(sftpstring)
|
|
9708
9801
|
sftpfile = upload_file_to_pysftp_file(ftpfileo, url)
|
|
9709
9802
|
sftpfileo.close()
|
|
9710
9803
|
return sftpfile
|
|
@@ -9806,8 +9899,9 @@ def upload_file_to_internet_string(ifp, url):
|
|
|
9806
9899
|
|
|
9807
9900
|
|
|
9808
9901
|
def upload_file_to_internet_compress_string(ifp, url, compression="auto", compressionlevel=None, compressionuselist=compressionlistalt, formatspecs=__file_format_dict__):
|
|
9902
|
+
internetfileo = MkTempFile(ifp)
|
|
9809
9903
|
fp = CompressOpenFileAlt(
|
|
9810
|
-
|
|
9904
|
+
internetfileo, compression, compressionlevel, compressionuselist, formatspecs)
|
|
9811
9905
|
if(not archivefileout):
|
|
9812
9906
|
return False
|
|
9813
9907
|
fp.seek(0, 0)
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
pyarchivefile.py,sha256=R5EI-PJ51bMbuTK-XbTyZes568b6jE80fRb_uGByLyI,439038
|
|
2
|
-
pyarchivefile-0.21.2.data/scripts/archivefile.py,sha256=K3zAhIF8grXnpxTzUJ08477Pe4gfwAjv9TtZOPTC-QA,14410
|
|
3
|
-
pyarchivefile-0.21.2.data/scripts/archiveneofile.py,sha256=m2jQVSnpapc2fd9R1fyvvERCNT3JLKymcwE5_bl0Rfk,5140
|
|
4
|
-
pyarchivefile-0.21.2.data/scripts/neoarchivefile.py,sha256=plAMPRkKOUeqogjs7mjoI3W8jIYVpVeSgA_MLwvbo68,7333
|
|
5
|
-
pyarchivefile-0.21.2.dist-info/licenses/LICENSE,sha256=WM1VWxTUVrQbvEa-LC7cKTaBHXiqSTyYPoJvsZSbd7E,1513
|
|
6
|
-
pyarchivefile-0.21.2.dist-info/METADATA,sha256=W_wuH5fuW-27fKuf-fHRda5GcMWw-Cyzdczpko8eMns,735
|
|
7
|
-
pyarchivefile-0.21.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
pyarchivefile-0.21.2.dist-info/top_level.txt,sha256=dXsHVLesKNVXuVZeri6pRuRPo3y1HrcPsUrIw5KU5fk,14
|
|
9
|
-
pyarchivefile-0.21.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
10
|
-
pyarchivefile-0.21.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|