persidict 0.30.0__tar.gz → 0.31.0__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.

Potentially problematic release.


This version of persidict might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: persidict
3
- Version: 0.30.0
3
+ Version: 0.31.0
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
  Keywords: persistence,dicts,distributed,parallel
6
6
  Author: Vlad (Volodymyr) Pavlov
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "persidict"
7
- version = "0.30.0"
7
+ version = "0.31.0"
8
8
  description = "Simple persistent key-value store for Python. Values are stored as files on a disk or as S3 objects on AWS cloud."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -29,4 +29,5 @@ from .file_dir_dict import FileDirDict
29
29
  from .s3_dict import S3Dict
30
30
  from .write_once_dict import WriteOnceDict
31
31
  from .jokers import Joker, KeepCurrentFlag, DeleteCurrentFlag
32
- from .jokers import KEEP_CURRENT, DELETE_CURRENT
32
+ from .jokers import KEEP_CURRENT, DELETE_CURRENT
33
+ from .overlapping_multi_dict import OverlappingMultiDict
@@ -0,0 +1,57 @@
1
+ from .persi_dict import PersiDict
2
+
3
+ class OverlappingMultiDict:
4
+ """A class that holds several PersiDict objects with different fyle_type-s.
5
+
6
+ The class is designed to be used as a container for several PersiDict objects
7
+ that have different file_type-s. All inner PersiDict objects
8
+ have the same dir_name attribute. Each inner PersiDict object is accessible
9
+ as an attribute of the OverlappingMultiDict object.
10
+ The attribute name is the same as the file_type
11
+ of the inner PersiDict object.
12
+
13
+ OverlappingMultiDict allows to store several PersiDict objects
14
+ in a single object, which can be useful for managing multiple types of data
15
+ in a single file directory or in an s3 bucket.
16
+
17
+ """
18
+ def __init__(self
19
+ , dict_type:type
20
+ , shared_subdicts_params:dict
21
+ , **individual_subdicts_params):
22
+ assert issubclass(dict_type, PersiDict)
23
+ assert isinstance(shared_subdicts_params, dict)
24
+ self.dict_type = dict_type
25
+ self.shared_subdicts_params = shared_subdicts_params
26
+ self.individual_subdicts_params = individual_subdicts_params
27
+ self.subdicts_names = list(individual_subdicts_params.keys())
28
+ for subdict_name in individual_subdicts_params:
29
+ assert isinstance(individual_subdicts_params[subdict_name], dict)
30
+ self.__dict__[subdict_name] = dict_type(
31
+ **{**shared_subdicts_params
32
+ ,**individual_subdicts_params[subdict_name]
33
+ ,"file_type":subdict_name})
34
+
35
+ def __getstate__(self):
36
+ raise TypeError("OverlappingMultiDict cannot be pickled.")
37
+
38
+ def __setstate__(self, state):
39
+ raise TypeError("OverlappingMultiDict cannot be pickled.")
40
+
41
+ def __getitem__(self, key):
42
+ raise TypeError(
43
+ "OverlappingMultiDict does not support item access by key. "
44
+ "Individual items should be accessed through nested dicts, "
45
+ f"which are available via attributes {self.subdicts_names}")
46
+
47
+ def __setitem__(self, key, value):
48
+ raise TypeError(
49
+ "OverlappingMultiDict does not support item assignment by key. "
50
+ "Individual items should be accessed through nested dicts, "
51
+ f"which are available via attributes {self.subdicts_names}")
52
+
53
+ def __delitem__(self, key):
54
+ raise TypeError(
55
+ "OverlappingMultiDict does not support item deletion by key. "
56
+ "Individual items can be deletedthrough nested dicts, "
57
+ f"which are available via attributes {self.subdicts_names}")
File without changes