lkj 0.1.45__py3-none-any.whl → 0.1.46__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.
lkj/strings.py CHANGED
@@ -741,7 +741,7 @@ def print_list(
741
741
  sep: str = ", ",
742
742
  line_prefix: str = "",
743
743
  items_per_line=None,
744
- show_count=True,
744
+ show_count: Union[bool, Callable[[int], str]] = False,
745
745
  title=None,
746
746
  print_func=print,
747
747
  ):
@@ -755,7 +755,7 @@ def print_list(
755
755
  sep: Separator for items
756
756
  line_prefix: Prefix for each line
757
757
  items_per_line: For columns style, how many items per line
758
- show_count: Whether to show the count of items
758
+ show_count: Whether to prefix with the count of items
759
759
  title: Optional title to display before the list
760
760
  print_func: Function to use for printing. Defaults to print.
761
761
  If None, returns the string instead of printing.
@@ -765,19 +765,16 @@ def print_list(
765
765
 
766
766
  # Wrapped style (default)
767
767
  >>> print_list(items, max_width=30)
768
- List (6 items):
769
768
  apple, banana, cherry, date,
770
769
  elderberry, fig
771
770
 
772
771
  # Columns style
773
772
  >>> print_list(items, style="columns", items_per_line=3)
774
- List (6 items):
775
773
  apple banana cherry
776
774
  date elderberry fig
777
775
 
778
776
  # Numbered style
779
777
  >>> print_list(items, style="numbered")
780
- List (6 items):
781
778
  1. apple
782
779
  2. banana
783
780
  3. cherry
@@ -787,7 +784,6 @@ def print_list(
787
784
 
788
785
  # Bullet style
789
786
  >>> print_list(items, style="bullet")
790
- List (6 items):
791
787
  • apple
792
788
  • banana
793
789
  • cherry
@@ -796,7 +792,7 @@ def print_list(
796
792
  • fig
797
793
 
798
794
  # Return string instead of printing
799
- >>> result = print_list(items, style="numbered", print_func=None)
795
+ >>> result = print_list(items, style="numbered", print_func=None, show_count=True)
800
796
  >>> print(result)
801
797
  List (6 items):
802
798
  1. apple
@@ -847,6 +843,8 @@ def print_list(
847
843
  print_func=print_func,
848
844
  )
849
845
  items = list(items) # Convert to list if it's an iterable
846
+ if show_count is True:
847
+ show_count = lambda n_items: f"List ({n_items} items):"
850
848
 
851
849
  # Handle print_func=None by using StringAppender
852
850
  if print_func is None:
@@ -860,7 +858,7 @@ def print_list(
860
858
  if title:
861
859
  print_func(title)
862
860
  elif show_count:
863
- print_func(f"List ({len(items)} items):")
861
+ print_func(show_count(len(items)))
864
862
 
865
863
  if not items:
866
864
  print_func(f"{line_prefix}(empty list)")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lkj
3
- Version: 0.1.45
3
+ Version: 0.1.46
4
4
  Summary: A dump of homeless useful utils
5
5
  Home-page: https://github.com/thorwhalen/lkj
6
6
  Author: Thor Whalen
@@ -7,9 +7,9 @@ lkj/importing.py,sha256=TcW3qUDmw7jqswpxXnksjlHkkbOJq70NbUk1ZyaafT0,6658
7
7
  lkj/iterables.py,sha256=9jeO36w-IGiZryge7JKgXZOGZAgehUvhwKV3nHPcZWk,2801
8
8
  lkj/loggers.py,sha256=ImmBdacz89Lvb3dg_xI5jOct_44rSRv0hNI_CVehy60,13706
9
9
  lkj/misc.py,sha256=IZf05tkl0cgiMgBwCMH5cLSC59fRXwnemPRo8G0OxQg,1436
10
- lkj/strings.py,sha256=aib3KLFBuHl2WuDI2m7xC2JXM9E2-fk9CkXU7Pld6VU,41459
11
- lkj-0.1.45.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
- lkj-0.1.45.dist-info/METADATA,sha256=J8VwBFxfxTERN8kVlzKROEz3kkz0FvILqflc6rFVxeI,8221
13
- lkj-0.1.45.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
14
- lkj-0.1.45.dist-info/top_level.txt,sha256=3DZOUwYmyurJFBXQCvCmEIVm8z2b42O5Sx3RDQyePfg,4
15
- lkj-0.1.45.dist-info/RECORD,,
10
+ lkj/strings.py,sha256=J3MD8sbXoaV7uACtue5v9QhAhFLjUCksf-cCTf9Ez5o,41509
11
+ lkj-0.1.46.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
+ lkj-0.1.46.dist-info/METADATA,sha256=Q7e2mCXrROS5o5HcDNEnsJO3WZQnW-AnR2-0eiOKLfY,8221
13
+ lkj-0.1.46.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
14
+ lkj-0.1.46.dist-info/top_level.txt,sha256=3DZOUwYmyurJFBXQCvCmEIVm8z2b42O5Sx3RDQyePfg,4
15
+ lkj-0.1.46.dist-info/RECORD,,
File without changes
File without changes