persidict 0.2.0__py3-none-any.whl → 0.2.2__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 +3 -0
- persidict/persi_dict.py +22 -13
- {persidict-0.2.0.dist-info → persidict-0.2.2.dist-info}/METADATA +2 -2
- persidict-0.2.2.dist-info/RECORD +11 -0
- persidict-0.2.0.dist-info/RECORD +0 -11
- {persidict-0.2.0.dist-info → persidict-0.2.2.dist-info}/LICENSE +0 -0
- {persidict-0.2.0.dist-info → persidict-0.2.2.dist-info}/WHEEL +0 -0
- {persidict-0.2.0.dist-info → persidict-0.2.2.dist-info}/top_level.txt +0 -0
persidict/__init__.py
CHANGED
|
@@ -17,6 +17,9 @@ S3_Dict (inherited from PersiDict): a dictionary that
|
|
|
17
17
|
stores key-value pairs as S3 objects on AWS.
|
|
18
18
|
A key is used to compose an objectname, while a value is stored
|
|
19
19
|
as a pickle or a json S3 object.
|
|
20
|
+
|
|
21
|
+
The package also offers a helper function get_safe_chars(),
|
|
22
|
+
which returns a set of URL/filename-safe characters permitted in keys.
|
|
20
23
|
"""
|
|
21
24
|
|
|
22
25
|
from .safe_str_tuple import SafeStrTuple, get_safe_chars
|
persidict/persi_dict.py
CHANGED
|
@@ -6,10 +6,14 @@ Python's built-in Dict, with a few variations
|
|
|
6
6
|
(e.g. insertion order is not preserved) and additional methods.
|
|
7
7
|
|
|
8
8
|
PersiDict persistently stores key-value pairs.
|
|
9
|
+
|
|
9
10
|
A key is a sequence of strings in a form of SafeStrTuple.
|
|
11
|
+
Regular strings and their sequences can also be passed to PersiDict as keys,
|
|
12
|
+
in this case they will be automatically converted to SafeStrTuple.
|
|
13
|
+
|
|
10
14
|
A value can be any Python object.
|
|
11
15
|
|
|
12
|
-
'
|
|
16
|
+
'Persistently' means that key-value pairs are saved in a durable storage,
|
|
13
17
|
such as a local hard-drive or AWS S3 cloud, and can be retrieved
|
|
14
18
|
even after the Python process that created the dictionary has terminated.
|
|
15
19
|
"""
|
|
@@ -22,11 +26,14 @@ from collections.abc import MutableMapping
|
|
|
22
26
|
|
|
23
27
|
from .safe_str_tuple import SafeStrTuple
|
|
24
28
|
|
|
25
|
-
PersiDictKey = Union[SafeStrTuple, str,
|
|
29
|
+
PersiDictKey = Union[SafeStrTuple, Sequence[str], str]
|
|
26
30
|
""" A value which can be used as a key for PersiDict.
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
PersiDict-s accept keys on a form of SafeStrTuple,
|
|
33
|
+
or a string, or a sequence of strings.
|
|
34
|
+
The characters within strings must be URL/filename-safe.
|
|
35
|
+
If a string (or a sequence of strings) is passed to a PersiDict as a key,
|
|
36
|
+
it will be automatically converted into SafeStrTuple.
|
|
30
37
|
"""
|
|
31
38
|
|
|
32
39
|
class PersiDict(MutableMapping):
|
|
@@ -195,11 +202,12 @@ class PersiDict(MutableMapping):
|
|
|
195
202
|
del self[k]
|
|
196
203
|
|
|
197
204
|
|
|
198
|
-
def
|
|
205
|
+
def delete_if_exists(self, key:PersiDictKey) -> bool:
|
|
199
206
|
""" Delete an item without raising an exception if it doesn't exist.
|
|
200
207
|
|
|
201
|
-
|
|
202
|
-
|
|
208
|
+
Returns True if the item existed and was deleted, False otherwise.
|
|
209
|
+
|
|
210
|
+
This method is absent in the original dict API.
|
|
203
211
|
"""
|
|
204
212
|
|
|
205
213
|
if self.immutable_items: # TODO: change to exceptions
|
|
@@ -207,21 +215,22 @@ class PersiDict(MutableMapping):
|
|
|
207
215
|
|
|
208
216
|
key = SafeStrTuple(key)
|
|
209
217
|
|
|
210
|
-
|
|
211
|
-
self
|
|
212
|
-
|
|
213
|
-
|
|
218
|
+
if key in self:
|
|
219
|
+
del self[key]
|
|
220
|
+
return True
|
|
221
|
+
else:
|
|
222
|
+
return False
|
|
214
223
|
|
|
215
224
|
|
|
216
225
|
def get_subdict(self, prefix_key:PersiDictKey) -> PersiDict:
|
|
217
|
-
"""Get a
|
|
226
|
+
"""Get a sub-dictionary containing items with the same prefix_key.
|
|
218
227
|
|
|
219
228
|
This method is absent in the original dict API.
|
|
220
229
|
"""
|
|
221
230
|
raise NotImplementedError
|
|
222
231
|
|
|
223
232
|
def subdicts(self) -> Dict[str, PersiDict]:
|
|
224
|
-
"""Get a dictionary of
|
|
233
|
+
"""Get a dictionary of sub-dictionaries.
|
|
225
234
|
|
|
226
235
|
This method is absent in the original dict API.
|
|
227
236
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: persidict
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Simple persistent key-value store for Python. Values are stored as files on a disk or as S3 objects on AWS cloud.
|
|
5
5
|
Home-page: https://github.com/vladlpavlov/persidict
|
|
6
6
|
Author: Vlad (Volodymyr) Pavlov
|
|
@@ -149,7 +149,7 @@ that simultaneously work with the same instance of a dictionary.
|
|
|
149
149
|
* Values must be pickleable Python objects.
|
|
150
150
|
* Insertion order is not preserved.
|
|
151
151
|
* You can not assign initial key-value pairs to a dictionary in its constructor.
|
|
152
|
-
* Methods `
|
|
152
|
+
* Methods `delete_if_exists()`, `mtimestamp()`, `get_subdict()` and `subdicts()`
|
|
153
153
|
are available
|
|
154
154
|
|
|
155
155
|
## Fine Tuning
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
persidict/__init__.py,sha256=bSOkH1e2bJuN4iFy2H4w6E3kmeODl0e7x3pUHExl_Uk,1030
|
|
2
|
+
persidict/file_dir_dict.py,sha256=-MYpUFK2ysPcrNz-gmJZOQeU18lJqlkDSI54IBSHOoA,9048
|
|
3
|
+
persidict/persi_dict.py,sha256=0waP8_soZ_msw_HfmxaaC8ZIPCPqhQnReMHLz706F5o,7908
|
|
4
|
+
persidict/s3_dict.py,sha256=0bVKxCdLcYVSfPeFrsqST2CE2-KQ1WpiOaLlu2WDgTc,9389
|
|
5
|
+
persidict/safe_str_tuple.py,sha256=Tia4O69QIn-htCM_WKQx_SyMNwOhLXrWcDlBRseCC2E,3547
|
|
6
|
+
persidict/safe_str_tuple_signing.py,sha256=OvGyaNOhx_I518nTifz3sRbej-vxtuRWqd4w1aEp8FY,3743
|
|
7
|
+
persidict-0.2.2.dist-info/LICENSE,sha256=oWpRWnm32aM5jVoboapPqgHi-drh1OPeZrrafyE1zTs,1113
|
|
8
|
+
persidict-0.2.2.dist-info/METADATA,sha256=_JQTDQtrXu9JmS5K3yzz5t1y1p8VJEghoB9pVGe9WK4,7834
|
|
9
|
+
persidict-0.2.2.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
|
|
10
|
+
persidict-0.2.2.dist-info/top_level.txt,sha256=7Kr8wnF-PGd513PbAORWUpp7Bi09VIZVTQS7ZN-dJXc,10
|
|
11
|
+
persidict-0.2.2.dist-info/RECORD,,
|
persidict-0.2.0.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
persidict/__init__.py,sha256=_tTjdl8d2bTbJJZPuK8Td4hR5EeoNx_iPtkIng0XWl4,898
|
|
2
|
-
persidict/file_dir_dict.py,sha256=-MYpUFK2ysPcrNz-gmJZOQeU18lJqlkDSI54IBSHOoA,9048
|
|
3
|
-
persidict/persi_dict.py,sha256=4pWDX5wDyIs96EoSXRFWGdyVVfZs3yj-_sc5w1-eC5g,7568
|
|
4
|
-
persidict/s3_dict.py,sha256=0bVKxCdLcYVSfPeFrsqST2CE2-KQ1WpiOaLlu2WDgTc,9389
|
|
5
|
-
persidict/safe_str_tuple.py,sha256=Tia4O69QIn-htCM_WKQx_SyMNwOhLXrWcDlBRseCC2E,3547
|
|
6
|
-
persidict/safe_str_tuple_signing.py,sha256=OvGyaNOhx_I518nTifz3sRbej-vxtuRWqd4w1aEp8FY,3743
|
|
7
|
-
persidict-0.2.0.dist-info/LICENSE,sha256=oWpRWnm32aM5jVoboapPqgHi-drh1OPeZrrafyE1zTs,1113
|
|
8
|
-
persidict-0.2.0.dist-info/METADATA,sha256=bTC16iN8LyUp1tz0hACMzrrJ_WjaP9tZ1o0CQy11ZxM,7830
|
|
9
|
-
persidict-0.2.0.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
|
|
10
|
-
persidict-0.2.0.dist-info/top_level.txt,sha256=7Kr8wnF-PGd513PbAORWUpp7Bi09VIZVTQS7ZN-dJXc,10
|
|
11
|
-
persidict-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|