From 8185da9addb2acff84d0307f8aa5b28a1fe98f38 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 13 Nov 2022 18:55:38 -0800 Subject: [PATCH] Fix typo mibibyte -> mebibyte. You guys were supposed to let me know!! How did I not notice this? --- voussoirkit/bytestring.py | 13 +++++++++---- voussoirkit/flasktools.py | 2 +- voussoirkit/spinal.py | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/voussoirkit/bytestring.py b/voussoirkit/bytestring.py index 8a2f0a2..7d38580 100644 --- a/voussoirkit/bytestring.py +++ b/voussoirkit/bytestring.py @@ -13,8 +13,8 @@ from voussoirkit import pipeable BYTE = 1 KIBIBYTE = 1024 * BYTE -MIBIBYTE = 1024 * KIBIBYTE -GIBIBYTE = 1024 * MIBIBYTE +MEBIBYTE = 1024 * KIBIBYTE +GIBIBYTE = 1024 * MEBIBYTE TEBIBYTE = 1024 * GIBIBYTE PEBIBYTE = 1024 * TEBIBYTE EXIBYTE = 1024 * PEBIBYTE @@ -23,7 +23,7 @@ YOBIBYTE = 1024 * ZEBIBYTE BYTE_STRING = 'b' KIBIBYTE_STRING = 'KiB' -MIBIBYTE_STRING = 'MiB' +MEBIBYTE_STRING = 'MiB' GIBIBYTE_STRING = 'GiB' TEBIBYTE_STRING = 'TiB' PEBIBYTE_STRING = 'PiB' @@ -31,10 +31,14 @@ EXIBYTE_STRING = 'EiB' ZEBIBYTE_STRING = 'ZiB' YOBIBYTE_STRING = 'YiB' +# backwards compatibility for a typo that survived way too long. +MIBIBYTE = MEBIBYTE +MIBIBYTE_STRING = MEBIBYTE_STRING + UNIT_STRINGS = { BYTE: BYTE_STRING, KIBIBYTE: KIBIBYTE_STRING, - MIBIBYTE: MIBIBYTE_STRING, + MEBIBYTE: MEBIBYTE_STRING, GIBIBYTE: GIBIBYTE_STRING, TEBIBYTE: TEBIBYTE_STRING, PEBIBYTE: PEBIBYTE_STRING, @@ -42,6 +46,7 @@ UNIT_STRINGS = { ZEBIBYTE: ZEBIBYTE_STRING, YOBIBYTE: YOBIBYTE_STRING, } + REVERSED_UNIT_STRINGS = {value: key for (key, value) in UNIT_STRINGS.items()} UNIT_SIZES = sorted(UNIT_STRINGS.keys(), reverse=True) diff --git a/voussoirkit/flasktools.py b/voussoirkit/flasktools.py index e17d619..5f63ed5 100644 --- a/voussoirkit/flasktools.py +++ b/voussoirkit/flasktools.py @@ -20,7 +20,7 @@ log = vlogging.get_logger(__name__) RNG = random.SystemRandom() GZIP_MINIMUM_SIZE = 500 * bytestring.BYTE -GZIP_MAXIMUM_SIZE = 5 * bytestring.MIBIBYTE +GZIP_MAXIMUM_SIZE = 5 * bytestring.MEBIBYTE GZIP_LEVEL = 3 REQUEST_TYPES = (flask.Request, werkzeug.wrappers.Request, werkzeug.local.LocalProxy) diff --git a/voussoirkit/spinal.py b/voussoirkit/spinal.py index 04a7f97..1f4879d 100644 --- a/voussoirkit/spinal.py +++ b/voussoirkit/spinal.py @@ -27,7 +27,7 @@ OVERWRITE_ALL = sentinel.Sentinel('overwrite all files') OVERWRITE_OLD = sentinel.Sentinel('overwrite old files') # Number of bytes to read and write at a time -CHUNK_SIZE = 2 * bytestring.MIBIBYTE +CHUNK_SIZE = 2 * bytestring.MEBIBYTE # When using dynamic chunk sizing, this is the ideal time to process a # single chunk, in seconds. @@ -506,7 +506,7 @@ def copy_file( dynamic_chunk_size = chunk_size == 'dynamic' if dynamic_chunk_size: - chunk_size = bytestring.MIBIBYTE + chunk_size = bytestring.MEBIBYTE while True: chunk_start = time.perf_counter() @@ -645,7 +645,7 @@ def hash_file( dynamic_chunk_size = chunk_size == 'dynamic' if dynamic_chunk_size: - chunk_size = bytestring.MIBIBYTE + chunk_size = bytestring.MEBIBYTE with handle: while True: