persidict 0.38.0__py3-none-any.whl → 0.103.0__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.
Potentially problematic release.
This version of persidict might be problematic. Click here for more details.
- persidict/__init__.py +41 -24
- persidict/basic_s3_dict.py +595 -0
- persidict/cached_appendonly_dict.py +247 -0
- persidict/cached_mutable_dict.py +248 -0
- persidict/empty_dict.py +171 -0
- persidict/file_dir_dict.py +130 -122
- persidict/local_dict.py +502 -0
- persidict/overlapping_multi_dict.py +23 -15
- persidict/persi_dict.py +281 -148
- persidict/s3_dict_file_dir_cached.py +215 -0
- persidict/{s3_dict.py → s3_dict_legacy.py} +111 -90
- persidict/safe_chars.py +13 -0
- persidict/safe_str_tuple.py +28 -6
- persidict/singletons.py +232 -0
- persidict/write_once_dict.py +47 -30
- {persidict-0.38.0.dist-info → persidict-0.103.0.dist-info}/METADATA +34 -24
- persidict-0.103.0.dist-info/RECORD +19 -0
- {persidict-0.38.0.dist-info → persidict-0.103.0.dist-info}/WHEEL +1 -1
- persidict/.DS_Store +0 -0
- persidict/jokers.py +0 -99
- persidict-0.38.0.dist-info/RECORD +0 -14
persidict/jokers.py
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"""Special singleton markers used to modify values in PersiDict without data payload.
|
|
2
|
-
|
|
3
|
-
This module defines two singleton flags used as "joker" values when writing to
|
|
4
|
-
persistent dictionaries:
|
|
5
|
-
|
|
6
|
-
- KEEP_CURRENT: keep the current value unchanged.
|
|
7
|
-
- DELETE_CURRENT: delete the current value if it exists.
|
|
8
|
-
|
|
9
|
-
These flags are intended to be passed as the value part in dict-style
|
|
10
|
-
assignments (e.g., d[key] = KEEP_CURRENT) and are interpreted by PersiDict
|
|
11
|
-
implementations.
|
|
12
|
-
|
|
13
|
-
Examples:
|
|
14
|
-
>>> from persidict.jokers import KEEP_CURRENT, DELETE_CURRENT
|
|
15
|
-
>>> d[key] = KEEP_CURRENT # Do not alter existing value
|
|
16
|
-
>>> d[key] = DELETE_CURRENT # Remove key if present
|
|
17
|
-
"""
|
|
18
|
-
from typing import Any
|
|
19
|
-
|
|
20
|
-
from parameterizable import (
|
|
21
|
-
ParameterizableClass
|
|
22
|
-
, register_parameterizable_class)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class Joker(ParameterizableClass):
|
|
26
|
-
"""Base class for singleton joker flags.
|
|
27
|
-
|
|
28
|
-
Implements a per-subclass singleton pattern and integrates with the
|
|
29
|
-
parameterizable framework. Subclasses represent value-less commands that
|
|
30
|
-
alter persistence behavior when assigned to a key.
|
|
31
|
-
|
|
32
|
-
Note:
|
|
33
|
-
This class uses a singleton pattern where each subclass maintains
|
|
34
|
-
exactly one instance that is returned on every instantiation.
|
|
35
|
-
"""
|
|
36
|
-
_instances: dict[type, "Joker"] = {}
|
|
37
|
-
|
|
38
|
-
def get_params(self) -> dict[str, Any]:
|
|
39
|
-
"""Return parameters for parameterizable API.
|
|
40
|
-
|
|
41
|
-
Returns:
|
|
42
|
-
dict[str, Any]: Always an empty dict for joker flags.
|
|
43
|
-
"""
|
|
44
|
-
return {}
|
|
45
|
-
|
|
46
|
-
def __new__(cls):
|
|
47
|
-
"""Create or return the singleton instance for the subclass.
|
|
48
|
-
|
|
49
|
-
Args:
|
|
50
|
-
cls: The class for which to create or retrieve the singleton instance.
|
|
51
|
-
|
|
52
|
-
Returns:
|
|
53
|
-
Joker: The singleton instance for the specified class.
|
|
54
|
-
"""
|
|
55
|
-
if cls not in Joker._instances:
|
|
56
|
-
Joker._instances[cls] = super().__new__(cls)
|
|
57
|
-
return Joker._instances[cls]
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class KeepCurrentFlag(Joker):
|
|
61
|
-
"""Flag instructing PersiDict to keep the current value unchanged.
|
|
62
|
-
|
|
63
|
-
Usage:
|
|
64
|
-
Assign this flag instead of a real value to indicate that an existing
|
|
65
|
-
value should not be modified.
|
|
66
|
-
|
|
67
|
-
Examples:
|
|
68
|
-
>>> d[key] = KEEP_CURRENT
|
|
69
|
-
|
|
70
|
-
Note:
|
|
71
|
-
This is a singleton class; constructing it repeatedly returns the same
|
|
72
|
-
instance.
|
|
73
|
-
"""
|
|
74
|
-
pass
|
|
75
|
-
|
|
76
|
-
class DeleteCurrentFlag(Joker):
|
|
77
|
-
"""Flag instructing PersiDict to delete the current value for a key.
|
|
78
|
-
|
|
79
|
-
Usage:
|
|
80
|
-
Assign this flag instead of a real value to remove the key if it
|
|
81
|
-
exists. If the key is absent, implementations will typically no-op.
|
|
82
|
-
|
|
83
|
-
Examples:
|
|
84
|
-
>>> d[key] = DELETE_CURRENT
|
|
85
|
-
|
|
86
|
-
Note:
|
|
87
|
-
This is a singleton class; constructing it repeatedly returns the same
|
|
88
|
-
instance.
|
|
89
|
-
"""
|
|
90
|
-
pass
|
|
91
|
-
|
|
92
|
-
register_parameterizable_class(KeepCurrentFlag)
|
|
93
|
-
register_parameterizable_class(DeleteCurrentFlag)
|
|
94
|
-
|
|
95
|
-
_KeepCurrent = KeepCurrentFlag()
|
|
96
|
-
KEEP_CURRENT = KeepCurrentFlag()
|
|
97
|
-
|
|
98
|
-
_DeleteCurrent = DeleteCurrentFlag()
|
|
99
|
-
DELETE_CURRENT = DeleteCurrentFlag()
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
persidict/.DS_Store,sha256=1lFlJ5EFymdzGAUAaI30vcaaLHt3F1LwpG7xILf9jsM,6148
|
|
2
|
-
persidict/__init__.py,sha256=CDOSJGgCnyRTkGUTzaeg3Cqsxwx0-0EFieOtldXwAls,1380
|
|
3
|
-
persidict/file_dir_dict.py,sha256=Wll343YPkYGyg3mLaOLwBakYLBPNieqKdWpxORIIwwA,29548
|
|
4
|
-
persidict/jokers.py,sha256=gTu7g2l2MIgBc3-hjvUrcwcgWs6tcbLyxB0u57M3bfU,3012
|
|
5
|
-
persidict/overlapping_multi_dict.py,sha256=UFyPEG2GbMmMHY48UmcaLHpsaxMqRH3bc_UA8S90yJo,5947
|
|
6
|
-
persidict/persi_dict.py,sha256=CKVHy8YELLRVgLWgo0Akbd8RznCVxqt8JHszIjqA_sI,23176
|
|
7
|
-
persidict/s3_dict.py,sha256=44jJPinE0bNHiCw2apFRzNZ_4IxIWOirIsLJqrObnuI,21428
|
|
8
|
-
persidict/safe_chars.py,sha256=H-cL9waCmDtwaRR5Y4b4oTzcBx09nc8wn8u61SVZDY0,1728
|
|
9
|
-
persidict/safe_str_tuple.py,sha256=YBTcYjUKIffznOawXb9xKjz4HaKdklrgyVtegJFmr5w,7202
|
|
10
|
-
persidict/safe_str_tuple_signing.py,sha256=mpOfx_xyprc0_c60XPB_EihI3vR1gOn6T03iCx1HwwQ,7494
|
|
11
|
-
persidict/write_once_dict.py,sha256=Fthmpltm2yK3FmpbNGV7KQVLhsroQenxwavG8Z95Jts,11649
|
|
12
|
-
persidict-0.38.0.dist-info/WHEEL,sha256=Pi5uDq5Fdo_Rr-HD5h9BiPn9Et29Y9Sh8NhcJNnFU1c,79
|
|
13
|
-
persidict-0.38.0.dist-info/METADATA,sha256=1bj8c9r174fLXJPJMVRa8gqvO8TklOSwo3psUt3b9fQ,12386
|
|
14
|
-
persidict-0.38.0.dist-info/RECORD,,
|