Make it possible for users of this library to override argparse's
[python_utils.git] / text_utils.py
index 0d07905be78daeb273995a0b5e131722e6e344d5..d9bb652689f8b317af606b4334a9e09604518975 100644 (file)
@@ -2,15 +2,14 @@
 
 """Utilities for dealing with "text"."""
 
-from collections import defaultdict
 import logging
 import math
 import sys
+from collections import defaultdict
 from typing import Dict, Generator, List, NamedTuple, Optional
 
 from ansi import fg, reset
 
-
 logger = logging.getLogger(__file__)
 
 
@@ -127,9 +126,7 @@ def distribute_strings(
     subwidth = math.floor(width / len(strings))
     retval = ""
     for string in strings:
-        string = justify_string(
-            string, width=subwidth, alignment=alignment, padding=padding
-        )
+        string = justify_string(string, width=subwidth, alignment=alignment, padding=padding)
         retval += string
     while len(retval) > width:
         retval = retval.replace('  ', ' ', 1)
@@ -151,13 +148,7 @@ def justify_string_by_chunk(string: str, width: int = 80, padding: str = " ") ->
     padding = padding[0]
     first, *rest, last = string.split()
     w = width - (len(first) + 1 + len(last) + 1)
-    ret = (
-        first
-        + padding
-        + distribute_strings(rest, width=w, padding=padding)
-        + padding
-        + last
-    )
+    ret = first + padding + distribute_strings(rest, width=w, padding=padding) + padding + last
     return ret