From c8fb56c601e62c23615819b5be10e015229f8305 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sun, 10 Dec 2023 10:41:09 -0800 Subject: [PATCH] formatting --- docs/utils.md | 37 +++++++++++++++++++------------------ jc/utils.py | 37 +++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/docs/utils.md b/docs/utils.md index b3abc43e..a4d45bc0 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -196,29 +196,30 @@ Parameters: (base-2) for ambiguous unit symbols and names, `False` to use decimal multiples of bytes (base-10). Returns: + integer/None Integer if successful conversion, otherwise None This function knows how to parse sizes in bytes, kilobytes, megabytes, gigabytes, terabytes and petabytes. Some examples: ->>> convert_size_to_int('42') -42 ->>> convert_size_to_int('13b') -13 ->>> convert_size_to_int('5 bytes') -5 ->>> convert_size_to_int('1 KB') -1000 ->>> convert_size_to_int('1 kilobyte') -1000 ->>> convert_size_to_int('1 KiB') -1024 ->>> convert_size_to_int('1 KB', binary=True) -1024 ->>> convert_size_to_int('1.5 GB') -1500000000 ->>> convert_size_to_int('1.5 GB', binary=True) -1610612736 + >>> convert_size_to_int('42') + 42 + >>> convert_size_to_int('13b') + 13 + >>> convert_size_to_int('5 bytes') + 5 + >>> convert_size_to_int('1 KB') + 1000 + >>> convert_size_to_int('1 kilobyte') + 1000 + >>> convert_size_to_int('1 KiB') + 1024 + >>> convert_size_to_int('1 KB', binary=True) + 1024 + >>> convert_size_to_int('1.5 GB') + 1500000000 + >>> convert_size_to_int('1.5 GB', binary=True) + 1610612736 diff --git a/jc/utils.py b/jc/utils.py index 224b123a..257f1f5a 100644 --- a/jc/utils.py +++ b/jc/utils.py @@ -309,29 +309,30 @@ def convert_size_to_int(size: str, binary: bool = False) -> Optional[int]: (base-2) for ambiguous unit symbols and names, `False` to use decimal multiples of bytes (base-10). Returns: + integer/None Integer if successful conversion, otherwise None This function knows how to parse sizes in bytes, kilobytes, megabytes, gigabytes, terabytes and petabytes. Some examples: - >>> convert_size_to_int('42') - 42 - >>> convert_size_to_int('13b') - 13 - >>> convert_size_to_int('5 bytes') - 5 - >>> convert_size_to_int('1 KB') - 1000 - >>> convert_size_to_int('1 kilobyte') - 1000 - >>> convert_size_to_int('1 KiB') - 1024 - >>> convert_size_to_int('1 KB', binary=True) - 1024 - >>> convert_size_to_int('1.5 GB') - 1500000000 - >>> convert_size_to_int('1.5 GB', binary=True) - 1610612736 + >>> convert_size_to_int('42') + 42 + >>> convert_size_to_int('13b') + 13 + >>> convert_size_to_int('5 bytes') + 5 + >>> convert_size_to_int('1 KB') + 1000 + >>> convert_size_to_int('1 kilobyte') + 1000 + >>> convert_size_to_int('1 KiB') + 1024 + >>> convert_size_to_int('1 KB', binary=True) + 1024 + >>> convert_size_to_int('1.5 GB') + 1500000000 + >>> convert_size_to_int('1.5 GB', binary=True) + 1610612736 """ def tokenize(text: str) -> List[str]: tokenized_input: List = []