relib 1.3.2__py3-none-any.whl → 1.3.3__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.
relib/iter_utils.py CHANGED
@@ -10,6 +10,7 @@ __all__ = [
10
10
  "interleave", "intersect",
11
11
  "list_split",
12
12
  "move_value",
13
+ "partition",
13
14
  "reversed_enumerate",
14
15
  "seekable", "sort_by",
15
16
  "transpose",
@@ -51,6 +52,15 @@ def list_split[T](iterable: Iterable[T], sep: T) -> list[list[T]]:
51
52
  ranges = list(zip(split_at[0:-1], split_at[1:]))
52
53
  return [values[start + 1:end] for start, end in ranges]
53
54
 
55
+ def partition[T](iterable: Iterable[tuple[bool, T]]) -> tuple[list[T], list[T]]:
56
+ true_values, false_values = [], []
57
+ for predicate, value in iterable:
58
+ if predicate:
59
+ true_values.append(value)
60
+ else:
61
+ false_values.append(value)
62
+ return true_values, false_values
63
+
54
64
  class seekable[T]:
55
65
  def __init__(self, iterable: Iterable[T]):
56
66
  self.index = 0
relib/runtime_tools.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import asyncio
2
2
  import contextvars
3
3
  import os
4
+ import sys
4
5
  from concurrent.futures import ThreadPoolExecutor
5
6
  from functools import partial, wraps
6
7
  from time import time
@@ -11,7 +12,7 @@ __all__ = [
11
12
  "as_async", "async_limit",
12
13
  "clear_console", "console_link",
13
14
  "default_executor", "default_workers",
14
- "roll_tasks",
15
+ "raise_if_interrupt", "roll_tasks",
15
16
  "measure_duration",
16
17
  ]
17
18
 
@@ -22,6 +23,10 @@ Coro = Coroutine[object, object, R]
22
23
  default_workers = min(32, (os.cpu_count() or 1) + 4)
23
24
  default_executor = ThreadPoolExecutor(max_workers=default_workers)
24
25
 
26
+ def raise_if_interrupt():
27
+ if sys.exc_info()[0] in (KeyboardInterrupt, SystemExit):
28
+ raise
29
+
25
30
  def clear_console() -> None:
26
31
  os.system("cls" if os.name == "nt" else "clear")
27
32
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relib
3
- Version: 1.3.2
3
+ Version: 1.3.3
4
4
  Project-URL: Repository, https://github.com/Reddan/relib.git
5
5
  Author: Hampus Hallman
6
6
  License: Copyright 2018-2025 Hampus Hallman
@@ -1,11 +1,11 @@
1
1
  relib/__init__.py,sha256=WerjUaM_sNvudjXFudLRtXB7viZWEW1RSinkDjrh4nE,163
2
2
  relib/dict_utils.py,sha256=jqW6bYSaQMt2AC2KFzDJKyl88idyMttWxXDu3t-fA5I,2980
3
3
  relib/io_utils.py,sha256=EtnIGQmLXjoHUPFteB5yPXDD3wGLvH4O3CahlCebXDQ,555
4
- relib/iter_utils.py,sha256=O2sXQ7Old7b9mkRczi-R8Gio92hpzSQl30TXsDS7PD4,5179
4
+ relib/iter_utils.py,sha256=r9tus9F_obwXsHE8Jk8H9_ZPdOgtBI6WnpDxI6La-to,5477
5
5
  relib/processing_utils.py,sha256=eMzjlxsEmfvtKafDITBWSp9D5RwegSWsUsvj1FpmBM0,1893
6
- relib/runtime_tools.py,sha256=KNtthODV1DdijABX_VIVbStbgT7Dlubu8oAEGxQsIhQ,2838
6
+ relib/runtime_tools.py,sha256=9N8gn3WCfqyS6D3Qs4l2nDja_NxDVVF-7hHIVrXA7Fc,2968
7
7
  relib/type_utils.py,sha256=oY96cAAux1JwhXgWFFyqEv_f-wwyPc_Hm6I9Yeisu_M,323
8
- relib-1.3.2.dist-info/METADATA,sha256=X3NdxQpaT122Rd0CM709I-rJUgUlbTbw3F3b0SwZMhQ,1295
9
- relib-1.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- relib-1.3.2.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
11
- relib-1.3.2.dist-info/RECORD,,
8
+ relib-1.3.3.dist-info/METADATA,sha256=3z1-dTnOlkjYiy54JQ2VQOs0zy5_kyP4Bk33l1YuAoQ,1295
9
+ relib-1.3.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ relib-1.3.3.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
11
+ relib-1.3.3.dist-info/RECORD,,
File without changes