zstdlib 0.10.10__tar.gz → 0.10.11__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 (48) hide show
  1. {zstdlib-0.10.10 → zstdlib-0.10.11}/PKG-INFO +1 -1
  2. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_ip_lock.py +7 -15
  3. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_keyed_instance.py +6 -6
  4. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/__init__.py +3 -8
  5. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/ansi.py +2 -0
  6. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/frozen.py +2 -0
  7. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/ip_lock.py +19 -11
  8. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/keyed_instance.py +4 -4
  9. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/log/cute.py +2 -0
  10. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/log/trace.py +2 -0
  11. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/not_set.py +2 -0
  12. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/signal_cm.py +4 -1
  13. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/singleton.py +2 -0
  14. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib.egg-info/PKG-INFO +1 -1
  15. {zstdlib-0.10.10 → zstdlib-0.10.11}/LICENSE +0 -0
  16. {zstdlib-0.10.10 → zstdlib-0.10.11}/README.md +0 -0
  17. {zstdlib-0.10.10 → zstdlib-0.10.11}/pyproject.toml +0 -0
  18. {zstdlib-0.10.10 → zstdlib-0.10.11}/setup.cfg +0 -0
  19. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/__init__.py +0 -0
  20. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/log/__init__.py +0 -0
  21. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/log/base.py +0 -0
  22. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/log/test_cute.py +0 -0
  23. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/log/test_trace.py +0 -0
  24. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_ansi.py +0 -0
  25. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_enum.py +0 -0
  26. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_exc_capture.py +0 -0
  27. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_frozen.py +0 -0
  28. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_hybridmethod.py +0 -0
  29. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_io.py +0 -0
  30. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_lazy.py +0 -0
  31. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_not_set.py +0 -0
  32. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_prompt.py +0 -0
  33. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_singleton.py +0 -0
  34. {zstdlib-0.10.10 → zstdlib-0.10.11}/tests/test_util.py +0 -0
  35. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/enum.py +0 -0
  36. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/exc_capture.py +0 -0
  37. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/hybridmethod.py +0 -0
  38. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/io.py +0 -0
  39. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/lazy.py +0 -0
  40. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/log/__init__.py +0 -0
  41. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/macos.py +0 -0
  42. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/prompt.py +0 -0
  43. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/py.typed +0 -0
  44. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib/util.py +0 -0
  45. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib.egg-info/SOURCES.txt +0 -0
  46. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib.egg-info/dependency_links.txt +0 -0
  47. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib.egg-info/requires.txt +0 -0
  48. {zstdlib-0.10.10 → zstdlib-0.10.11}/zstdlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zstdlib
3
- Version: 0.10.10
3
+ Version: 0.10.11
4
4
  Summary: A set of useful python utilities
5
5
  License-Expression: GPL-3.0-only
6
6
  Project-URL: Homepage, https://github.com/zwimer/zstdlib
@@ -9,16 +9,8 @@ import unittest
9
9
  import time
10
10
  import os
11
11
 
12
- from zstdlib import (
13
- GlobalIPLock as GIPL,
14
- AbstractIPLock,
15
- IPLock,
16
- RIPLock,
17
- LockHung,
18
- LockPathInUse,
19
- NotAcquired,
20
- normpath,
21
- )
12
+ from zstdlib.ip_lock import LockPathInUseError, NotAcquiredError, AbstractIPLock, LockHungError
13
+ from zstdlib import GlobalIPLock as GIPL, RIPLock, IPLock, normpath
22
14
 
23
15
  DELAY = 0.25 # Lower is faster but less accurate
24
16
 
@@ -206,7 +198,7 @@ class TestGlobalProcessLock(unittest.TestCase):
206
198
  lock.release()
207
199
  self.assertFalse(lock.acquired)
208
200
  # Release 3/2
209
- with self.assertRaises(NotAcquired):
201
+ with self.assertRaises(NotAcquiredError):
210
202
  lock.release()
211
203
  self.assertFalse(lock.acquired)
212
204
  # CM exit, lock file removed by NTF
@@ -285,7 +277,7 @@ class TestIPLocks(unittest.TestCase):
285
277
  # pylint: enable=protected-access
286
278
  # Test releasing when we don't have
287
279
  self.assertFalse(lock.acquired)
288
- with self.assertRaises(NotAcquired):
280
+ with self.assertRaises(NotAcquiredError):
289
281
  lock.release()
290
282
  # pylint: disable=protected-access
291
283
  lock._rc += 1
@@ -334,15 +326,15 @@ class TestIPLocks(unittest.TestCase):
334
326
  self.assertFalse(rlock.acquired)
335
327
  del rlock
336
328
 
337
- with mk_lock(IPLock) as lock, self.assertRaises(LockPathInUse):
329
+ with mk_lock(IPLock) as lock, self.assertRaises(LockPathInUseError):
338
330
  _ = RIPLock(lock.path)
339
331
  del lock
340
- with mk_lock(RIPLock) as rlock, self.assertRaises(LockPathInUse):
332
+ with mk_lock(RIPLock) as rlock, self.assertRaises(LockPathInUseError):
341
333
  _ = IPLock(rlock.path)
342
334
  del rlock
343
335
 
344
336
  def test_lock_hung(self) -> None:
345
- with mk_lock(IPLock) as lock, enter(lock), self.assertRaises(LockHung):
337
+ with mk_lock(IPLock) as lock, enter(lock), self.assertRaises(LockHungError):
346
338
  _ = lock.acquire()
347
339
 
348
340
 
@@ -12,8 +12,8 @@ import time
12
12
  import sys
13
13
  import os
14
14
 
15
- from zstdlib.keyed_instance import KeyedInstanceProcessError
16
- from zstdlib import CircularConstruction, KeyedInstance
15
+ from zstdlib.keyed_instance import CircularConstructionError, KeyedInstanceProcessError
16
+ from zstdlib import KeyedInstance
17
17
 
18
18
 
19
19
  class Nop:
@@ -129,14 +129,14 @@ class TestKeyedInstance(unittest.TestCase):
129
129
  def __init__(self, b: bool) -> None:
130
130
  self.same = type(self)(b) # Father is self, circle
131
131
 
132
- with self.assertRaises(CircularConstruction):
132
+ with self.assertRaises(CircularConstructionError):
133
133
  _ = Crazy(True)
134
134
 
135
135
  class Crazy2(KeyedInstance):
136
136
  def __init__(self, b: bool) -> None:
137
137
  self.inverse = type(self)(not b) # Grandfather is self
138
138
 
139
- with self.assertRaises(CircularConstruction):
139
+ with self.assertRaises(CircularConstructionError):
140
140
  _ = Crazy2(True)
141
141
 
142
142
  def test_multiproc(self) -> None:
@@ -249,8 +249,8 @@ class TestKeyedInstance(unittest.TestCase):
249
249
  "5 | Thread-1 | C1(0), next=[0, 0] - err: C2(0)", # release C2(0)
250
250
  ]
251
251
  self.assertEqual(Action.strs(actions), expected)
252
- self.assertIsInstance(fail1, CircularConstruction)
253
- self.assertIsInstance(fail2, CircularConstruction)
252
+ self.assertIsInstance(fail1, CircularConstructionError)
253
+ self.assertIsInstance(fail2, CircularConstructionError)
254
254
  self.assertIsNot(fail1, fail2)
255
255
 
256
256
  # Test simultaneous construction
@@ -1,9 +1,9 @@
1
- __version__ = "0.10.10"
1
+ __version__ = "0.10.11"
2
2
 
3
- from .ip_lock import AbstractIPLock, GlobalIPLock, IPLock, LockHung, LockPathInUse, NotAcquired, RIPLock
4
- from .keyed_instance import CircularConstruction, KeyedInstance
5
3
  from .prompt import prompt_until, prompt_for, yn_prompt
4
+ from .ip_lock import GlobalIPLock, IPLock, RIPLock
6
5
  from .exc_capture import ExcCapture, ExcDelay
6
+ from .keyed_instance import KeyedInstance
7
7
  from .hybridmethod import hybridmethod
8
8
  from .not_set import NotSetType, NotSet
9
9
  from .frozen import Freezable, frozen
@@ -14,8 +14,6 @@ from .util import normpath
14
14
  from . import macos, lazy, log, io
15
15
 
16
16
  __all__ = (
17
- "AbstractIPLock",
18
- "CircularConstruction",
19
17
  "Enum",
20
18
  "ExcCapture",
21
19
  "ExcDelay",
@@ -23,9 +21,6 @@ __all__ = (
23
21
  "GlobalIPLock",
24
22
  "IPLock",
25
23
  "KeyedInstance",
26
- "LockHung",
27
- "LockPathInUse",
28
- "NotAcquired",
29
24
  "NotSet",
30
25
  "NotSetType",
31
26
  "RIPLock",
@@ -3,6 +3,8 @@ from typing import Self, cast
3
3
  from functools import cache
4
4
  import re
5
5
 
6
+ __all__ = ("MODIFIERS", "Color", "PureColor", "RawColor")
7
+
6
8
  MODIFIERS = ("bold", "dim", "italic", "underline", "blinking", "inverse", "hidden", "strikethrough")
7
9
 
8
10
  _PREFIX = "\033["
@@ -1,6 +1,8 @@
1
1
  from typing import Protocol, Any, overload
2
2
  from collections.abc import Callable
3
3
 
4
+ __all__ = ("Freezable", "frozen")
5
+
4
6
  _FN_ATTRS = (
5
7
  "__annotations__",
6
8
  "__type_params__",
@@ -10,14 +10,22 @@ from fasteners import InterProcessLock
10
10
  from .keyed_instance import KeyedInstance
11
11
  from .util import normpath
12
12
 
13
- __all__ = ("AbstractIPLock", "GlobalIPLock", "IPLock", "LockHung", "LockPathInUse", "NotAcquired", "RIPLock")
13
+ __all__ = (
14
+ "AbstractIPLock",
15
+ "GlobalIPLock",
16
+ "IPLock",
17
+ "LockHungError",
18
+ "LockPathInUseError",
19
+ "NotAcquiredError",
20
+ "RIPLock",
21
+ )
14
22
 
15
23
 
16
- class NotAcquired(RuntimeError):
24
+ class NotAcquiredError(RuntimeError):
17
25
  """Raised by AbstractIPLock.release if a lock is not acquired"""
18
26
 
19
27
 
20
- class LockHung(RuntimeError):
28
+ class LockHungError(RuntimeError):
21
29
  """Raised when a non-reentrant lock attempts to reenter with blocking=True and no timeout"""
22
30
 
23
31
 
@@ -42,7 +50,7 @@ class AbstractIPLock(ABC):
42
50
 
43
51
  @abstractmethod
44
52
  def release(self) -> None:
45
- """Release the lock, raises NotAcquired if not self.acquired"""
53
+ """Release the lock, raises NotAcquiredError if not self.acquired"""
46
54
 
47
55
  # Concrete methods
48
56
 
@@ -160,7 +168,7 @@ class GlobalIPLock(KeyedInstance, AbstractIPLock):
160
168
  def release(self) -> None:
161
169
  """Release the lock"""
162
170
  if not self.acquired:
163
- raise NotAcquired(f"{self.__class__.__name__}: {self.path}")
171
+ raise NotAcquiredError(f"{self.__class__.__name__}: {self.path}")
164
172
  with self._t_lock:
165
173
  assert bool(self._rc) == self._ip_lock.acquired
166
174
  if self._rc <= 1:
@@ -169,7 +177,7 @@ class GlobalIPLock(KeyedInstance, AbstractIPLock):
169
177
  assert bool(self._rc) == self._ip_lock.acquired
170
178
 
171
179
 
172
- class LockPathInUse(LookupError):
180
+ class LockPathInUseError(LookupError):
173
181
  """
174
182
  Raised when a user attempts to create an IPLock lock for a given
175
183
  GlobalIPLock that already exists with a different reentrancy setting
@@ -195,7 +203,7 @@ class _IPLock(AbstractIPLock):
195
203
  def __init__(self, gipl: GlobalIPLock | Path | str, *args: Any, **kwargs: Any) -> None:
196
204
  """
197
205
  Construct an inter process lock syncronized by gipl (or GlobalIPLock.new(gipl) if str | Path)
198
- If a lock of a different reentrancy setting already exists for this gipl, raise LockPathInUse
206
+ If a lock of a different reentrancy setting already exists for this gipl, raise LockPathInUseError
199
207
  """
200
208
  super().__init__(*args, **kwargs) # For MRO superclasses
201
209
  if isinstance(gipl, Path | str):
@@ -209,7 +217,7 @@ class _IPLock(AbstractIPLock):
209
217
  got = (self._cls_reentrant, Lock())
210
218
  self._data[gipl.path] = got
211
219
  if got[0] != self._cls_reentrant:
212
- raise LockPathInUse(f"Want reentrant={self._cls_reentrant} but existing lock is the opposite")
220
+ raise LockPathInUseError(f"reentrant={self._cls_reentrant} but existing lock is the opposite")
213
221
  self._instance_reentrant: Final[bool] = got[0]
214
222
  self._sync_lock: Final[Lock] = got[1]
215
223
  self._instance_lock: Final[Lock] = Lock() # Allow multiple threads to use this instance at once
@@ -237,7 +245,7 @@ class _IPLock(AbstractIPLock):
237
245
  acquired = self.acquired
238
246
  if acquired and not self._instance_reentrant:
239
247
  if timeout_per is None:
240
- raise LockHung(f"{self.__class__.__name__}: {self.path}")
248
+ raise LockHungError(f"{self.__class__.__name__}: {self.path}")
241
249
  return ret
242
250
  timeout = -1 if timeout_per is None else timeout_per
243
251
  if acquired or self._sync_lock.acquire(blocking, timeout=timeout):
@@ -253,7 +261,7 @@ class _IPLock(AbstractIPLock):
253
261
  """Release the lock"""
254
262
  with self._instance_lock:
255
263
  if not self.acquired:
256
- raise NotAcquired(f"{self.__class__.__name__}: {self.path}")
264
+ raise NotAcquiredError(f"{self.__class__.__name__}: {self.path}")
257
265
  self._rc -= 1
258
266
  if self._rc == 0:
259
267
  try:
@@ -264,7 +272,7 @@ class _IPLock(AbstractIPLock):
264
272
  raise
265
273
  try:
266
274
  self._gipl.release()
267
- except NotAcquired as e:
275
+ except NotAcquiredError as e:
268
276
  raise OSError("The GlobalIPLock lock was already unlocked by something else") from e
269
277
 
270
278
 
@@ -4,10 +4,10 @@ from collections.abc import Hashable
4
4
  from abc import ABCMeta
5
5
  import sys
6
6
 
7
- __all__ = ("CircularConstruction", "KeyedInstance", "KeyedInstanceProcessError")
7
+ __all__ = ("CircularConstructionError", "KeyedInstance", "KeyedInstanceProcessError")
8
8
 
9
9
 
10
- class CircularConstruction(RuntimeError):
10
+ class CircularConstructionError(RuntimeError):
11
11
  """Raised when keyed constructors form a circular dependency."""
12
12
 
13
13
  def __init__(self, type_: type) -> None:
@@ -101,7 +101,7 @@ class _KeyedInstanceMeta(ABCMeta):
101
101
  break
102
102
  blocking = dependency.tid
103
103
  else:
104
- raise CircularConstruction(cls)
104
+ raise CircularConstructionError(cls)
105
105
 
106
106
  # Wait for a thread to finish construction then recheck if we can start
107
107
  condition.wait()
@@ -139,7 +139,7 @@ class KeyedInstance(metaclass=_KeyedInstanceMeta):
139
139
  The first thread to claim a cache key performs construction. If
140
140
  construction fails, another waiting thread can attempt construction.
141
141
 
142
- If items being constructed require constructing each other, a CircularConstruction is raised
142
+ If items being constructed require constructing each other, a CircularConstructionError is raised
143
143
 
144
144
  Do not mix this with fork (uses thread ids internally); multiprocessing spawn is ok
145
145
  """
@@ -9,6 +9,8 @@ from ..ansi import PureColor, RawColor, Color
9
9
  if TYPE_CHECKING:
10
10
  from logging import LogRecord
11
11
 
12
+ __all__ = ("CuteFormatter",)
13
+
12
14
 
13
15
  class CuteFormatter(Formatter):
14
16
  """A log formatter that can print log messages with colors."""
@@ -2,6 +2,8 @@ from threading import Lock
2
2
  from typing import Any
3
3
  import logging
4
4
 
5
+ __all__ = ("install",)
6
+
5
7
 
6
8
  class _State:
7
9
  __init__ = NotImplemented
@@ -1,5 +1,7 @@
1
1
  from .singleton import Singleton
2
2
 
3
+ __all__ = ("NotSet", "NotSetType")
4
+
3
5
 
4
6
  # Remove in python3.15
5
7
  class NotSetType(Singleton):
@@ -2,13 +2,16 @@ from collections.abc import Callable, Iterator
2
2
  from contextlib import contextmanager
3
3
  from logging import getLogger
4
4
  from types import FrameType
5
+ from typing import Any
5
6
  import signal
6
7
 
8
+ __all__ = ("signal_cm",)
9
+
7
10
 
8
11
  @contextmanager
9
12
  def signal_cm(
10
13
  signalnum: signal.Signals | int,
11
- handler: signal.Handlers | Callable[[int, FrameType | None], None],
14
+ handler: signal.Handlers | Callable[[int, FrameType | None], Any],
12
15
  *,
13
16
  disable_logging: bool = False,
14
17
  ) -> Iterator[None]:
@@ -3,6 +3,8 @@ from collections import defaultdict
3
3
  from threading import RLock
4
4
  from functools import cache
5
5
 
6
+ __all__ = ("NoInstanceError", "Singleton")
7
+
6
8
 
7
9
  class NoInstanceError(TypeError):
8
10
  """A TypeError raised when trying to get a Singleton instance before constructing it"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zstdlib
3
- Version: 0.10.10
3
+ Version: 0.10.11
4
4
  Summary: A set of useful python utilities
5
5
  License-Expression: GPL-3.0-only
6
6
  Project-URL: Homepage, https://github.com/zwimer/zstdlib
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes