kisstdlib 0.0.13__tar.gz → 0.0.14__tar.gz

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.
Files changed (47) hide show
  1. {kisstdlib-0.0.13/kisstdlib.egg-info → kisstdlib-0.0.14}/PKG-INFO +1 -1
  2. kisstdlib-0.0.14/VERSION +1 -0
  3. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/base.py +43 -24
  4. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/collections_ext.py +2 -2
  5. kisstdlib-0.0.14/kisstdlib/fs.py +1486 -0
  6. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/logging_ext.py +18 -1
  7. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/time.py +236 -220
  8. {kisstdlib-0.0.13 → kisstdlib-0.0.14/kisstdlib.egg-info}/PKG-INFO +1 -1
  9. kisstdlib-0.0.14/test/test_fs.py +772 -0
  10. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/test/test_time.py +154 -75
  11. kisstdlib-0.0.13/VERSION +0 -1
  12. kisstdlib-0.0.13/kisstdlib/fs.py +0 -1175
  13. kisstdlib-0.0.13/test/test_fs.py +0 -343
  14. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/LICENSE.txt +0 -0
  15. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/README.md +0 -0
  16. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/__init__.py +0 -0
  17. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/argparse_ext.py +0 -0
  18. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/compression.py +0 -0
  19. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/failure.py +0 -0
  20. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/getpass_ext.py +0 -0
  21. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/io/__init__.py +0 -0
  22. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/io/adapter.py +0 -0
  23. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/io/base.py +0 -0
  24. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/io/encoder.py +0 -0
  25. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/io/stdio.py +0 -0
  26. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/io/wrapper.py +0 -0
  27. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/itertools_ext.py +0 -0
  28. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/parsing.py +0 -0
  29. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/py.typed +0 -0
  30. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/pyrepr.py +0 -0
  31. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/signal_ext.py +0 -0
  32. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/sqlite3_ext.py +0 -0
  33. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/string_ext.py +0 -0
  34. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib/tariter.py +0 -0
  35. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib.egg-info/SOURCES.txt +0 -0
  36. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib.egg-info/dependency_links.txt +0 -0
  37. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib.egg-info/entry_points.txt +0 -0
  38. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib.egg-info/requires.txt +0 -0
  39. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib.egg-info/top_level.txt +0 -0
  40. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/kisstdlib_bin/describe_forest.py +0 -0
  41. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/pyproject.toml +0 -0
  42. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/setup.cfg +0 -0
  43. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/setup.py +0 -0
  44. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/test/test_basics.py +0 -0
  45. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/test/test_collections.py +0 -0
  46. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/test/test_io.py +0 -0
  47. {kisstdlib-0.0.13 → kisstdlib-0.0.14}/test/test_parsing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kisstdlib
3
- Version: 0.0.13
3
+ Version: 0.0.14
4
4
  Summary: System programming with conceptually and algebraically simple primitives.
5
5
  Author-email: Jan Malakhovski <oxij@oxij.org>
6
6
  Project-URL: Homepage, https://oxij.org/software/kisstdlib/
@@ -0,0 +1 @@
1
+ 0.0.14
@@ -173,34 +173,33 @@ def is_closer[A: SupportsCounting](ideal: A, a: A, b: A) -> bool:
173
173
  return abs(ideal - a) < abs(ideal - b)
174
174
 
175
175
 
176
- ### Simple functions
176
+ ### Exception handling hooks
177
177
 
178
178
 
179
- def noop() -> None:
180
- """A noop."""
179
+ def raise_one(exc: Exception, /, *_args: _t.Any, **_kwargs: _t.Any) -> _t.NoReturn:
180
+ """Raise the given `Exception`."""
181
+ raise exc
181
182
 
182
183
 
183
- def noop_(*_args: _t.Any, **_kwargs: _t.Any) -> None:
184
- """A noop, with a bunch of ignored arguments."""
184
+ def raise_all(excs: list[Exception], /, *_args: _t.Any, **_kwargs: _t.Any) -> _t.NoReturn:
185
+ """Raise give exceptions as a trivial `ExceptionGroup`."""
186
+ raise ExceptionGroup("multiple failures", excs)
185
187
 
186
188
 
187
- def identity[T](x: T, /) -> T:
188
- """Identity function."""
189
- return x
189
+ ### Simple functions
190
190
 
191
191
 
192
- def identity_[T](x: T, /, *_args: _t.Any, **_kwargs: _t.Any) -> T:
193
- """Identity function, with a bunch of ignored arguments."""
194
- return x
192
+ def noop(*_args: _t.Any, **_kwargs: _t.Any) -> None:
193
+ """A noop, with a bunch of ignored arguments."""
195
194
 
196
195
 
197
- def const[A, B](x: A, /) -> _t.Callable[[B], A]:
198
- """Return a function that always returns `a`."""
199
- return lambda y: x
196
+ def identity[T](x: T, /, *_args: _t.Any, **_kwargs: _t.Any) -> T:
197
+ """Identity function, with a bunch of ignored arguments."""
198
+ return x
200
199
 
201
200
 
202
- def const_[A, B, **PS](x: A, /) -> _t.Callable[_t.Concatenate[B, PS], A]:
203
- """Return a function that always returns `a`, and has a bunch of ignored arguments."""
201
+ def const[A, B, **PS](x: A, /) -> _t.Callable[_t.Concatenate[B, PS], A]:
202
+ """Return a function that always returns `a`, with a bunch of ignored arguments."""
204
203
 
205
204
  def sub(_y: B, /, *_args: PS.args, **_kwargs: PS.kwargs) -> A:
206
205
  return x
@@ -312,24 +311,44 @@ def map_right[A, B, C](f: _t.Callable[[B], C], x: Either[A, B]) -> Either[A, C]:
312
311
  ### Function composition
313
312
 
314
313
 
315
- def compose[A, B, C](f: _t.Callable[[B], C], g: _t.Callable[[A], B]) -> _t.Callable[[A], C]:
316
- return lambda x: f(g(x))
314
+ def compose[A, B, C, **PS](
315
+ f: _t.Callable[[B], C], g: _t.Callable[_t.Concatenate[A, PS], B]
316
+ ) -> _t.Callable[_t.Concatenate[A, PS], C]:
317
+ """Compose two functions `f` and `g` while passing all the additional `PS` arguments to `g`."""
318
+
319
+ def sub(x: A, /, *args: PS.args, **kwargs: PS.kwargs) -> C:
320
+ return f(g(x, *args, **kwargs))
321
+
322
+ return sub
323
+
324
+
325
+ def compose_wide[A, B, C, **PS](
326
+ f: _t.Callable[_t.Concatenate[B, PS], C], g: _t.Callable[_t.Concatenate[A, PS], B]
327
+ ) -> _t.Callable[_t.Concatenate[A, PS], C]:
328
+ """Compose two functions `f` and `g` while passing all the additional `PS` arguments to both `f`
329
+ and `g`.
330
+ """
331
+
332
+ def sub(x: A, /, *args: PS.args, **kwargs: PS.kwargs) -> C:
333
+ return f(g(x, *args, **kwargs), *args, **kwargs)
334
+
335
+ return sub
317
336
 
318
337
 
319
338
  def compose_pipe[A, **PS](
320
339
  pipe: list[_t.Callable[_t.Concatenate[A, PS], A]], /
321
340
  ) -> _t.Callable[_t.Concatenate[A, PS], A]:
322
- """Compose a list of functions, similarly to how a shell pipe ("|")
323
- exression does it. I.e. compose them in reverse order.
341
+ """Compose a list of functions, similarly to how a shell pipe ("|") exression does it. I.e.
342
+ compose them in reverse order.
324
343
 
325
- The mutating value gets passed as the first argument, all other
326
- arguments get passed unchanged.
344
+ The mutating value gets passed as the first argument, all other arguments get passed unchanged
345
+ like with `compose_wide`.
327
346
 
328
- `compose_pipe([])` is `identity_`.
347
+ `compose_pipe([])` is `identity`.
329
348
  `compose_pipe([x])` is `x`.
330
349
  """
331
350
  if len(pipe) == 0:
332
- return identity_
351
+ return identity
333
352
  if len(pipe) == 1:
334
353
  return pipe[0]
335
354
 
@@ -43,7 +43,7 @@ from .base import (
43
43
  SupportsCounting as _SupportsCounting,
44
44
  is_infinite as _is_infinite,
45
45
  is_closer as _is_closer,
46
- noop_ as _noop_,
46
+ noop as _noop,
47
47
  )
48
48
  from .itertools_ext import (
49
49
  chain as _chain,
@@ -66,7 +66,7 @@ class LRUCache[Key, Value](OrderedDict[Key, Value]):
66
66
  """
67
67
 
68
68
  def __init__(
69
- self, maxsize: int | None = None, onevict: _t.Callable[[Key, Value], None] = _noop_
69
+ self, maxsize: int | None = None, onevict: _t.Callable[[Key, Value], None] = _noop
70
70
  ) -> None:
71
71
  self.maxsize = maxsize
72
72
  self.onevict = onevict