Skip to content

Commit 3a9c0ce

Browse files
Add files via upload
1 parent 73fdd2c commit 3a9c0ce

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

pycatfile.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ def _is_printable(ch):
416416
__use_inmemfile__ = True
417417
__use_spoolfile__ = False
418418
__use_spooldir__ = tempfile.gettempdir()
419+
BYTES_PER_MiB = 1024 * 1024
420+
DEFAULT_SPOOL_MAX = 8 * BYTES_PER_MiB
421+
__use_spooldir__ = DEFAULT_SPOOL_MAX
419422
__program_name__ = "Py"+__file_format_default__
420423
__use_env_file__ = True
421424
__use_ini_file__ = True
@@ -1974,7 +1977,7 @@ def MkTempFile(data=None,
19741977
dir=None,
19751978
suffix="",
19761979
use_spool=__use_spoolfile__,
1977-
spool_max=8 * 1024 * 1024,
1980+
spool_max=__use_spooldir__,
19781981
spool_dir=__use_spooldir__):
19791982
"""
19801983
Return a file-like handle with consistent behavior on Py2.7 and Py3.x.
@@ -2418,7 +2421,7 @@ class ZlibFile(object):
24182421

24192422
def __init__(self, file_path=None, fileobj=None, mode='rb', level=6, wbits=15,
24202423
encoding=None, errors=None, newline=None,
2421-
tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=(8 << 20)):
2424+
tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=__use_spooldir__):
24222425

24232426
if file_path is None and fileobj is None:
24242427
raise ValueError("Either file_path or fileobj must be provided")
@@ -2905,7 +2908,7 @@ class GzipFile(object):
29052908

29062909
def __init__(self, file_path=None, fileobj=None, mode='rb',
29072910
level=6, encoding=None, errors=None, newline=None,
2908-
tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=(8 << 20)):
2911+
tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=__use_spooldir__):
29092912

29102913
if file_path is None and fileobj is None:
29112914
raise ValueError("Either file_path or fileobj must be provided")
@@ -3351,7 +3354,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb',
33513354
level=9, encoding=None, errors=None, newline=None,
33523355
write_header=True,
33533356
tolerant_read=False, scan_bytes=(64 << 10),
3354-
spool_threshold=(8 << 20)):
3357+
spool_threshold=__use_spooldir__):
33553358
"""
33563359
Custom LZO file (NOT the lzop(1) format).
33573360
- streaming write/read, supports concatenated members
@@ -3826,7 +3829,7 @@ def lzop_compress_bytes(payload, level=9, text=False, **kw):
38263829

38273830

38283831
def lzop_decompress_bytes(blob, mode='rb', tolerant_read=False, scan_bytes=(64 << 10),
3829-
spool_threshold=(8 << 20), **kw):
3832+
spool_threshold=__use_spooldir__, **kw):
38303833
"""
38313834
Decompress bytes produced by this custom container.
38323835
- mode='rb' -> returns bytes; mode='rt' -> returns text (set encoding/errors/newline in kw)
@@ -9794,7 +9797,7 @@ def fast_copy(infp, outfp, bufsize=1 << 20):
97949797
outfp.write(data)
97959798

97969799

9797-
def copy_file_to_mmap_dest(src_path, outfp, chunk_size=8 << 20):
9800+
def copy_file_to_mmap_dest(src_path, outfp, chunk_size=__use_spooldir__):
97989801
"""
97999802
Copy a disk file into an mmap-backed destination (FileLikeAdapter).
98009803
Falls back to buffered copy if the source cannot be mmapped.

0 commit comments

Comments
 (0)