oldaplib 0.3.0__py3-none-any.whl → 0.3.1__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.
- oldaplib/src/helpers/observable_dict.py +26 -2
- oldaplib/src/version.py +1 -1
- oldaplib/test/test_observable_dict.py +1 -1
- {oldaplib-0.3.0.dist-info → oldaplib-0.3.1.dist-info}/METADATA +1 -1
- {oldaplib-0.3.0.dist-info → oldaplib-0.3.1.dist-info}/RECORD +6 -6
- {oldaplib-0.3.0.dist-info → oldaplib-0.3.1.dist-info}/WHEEL +0 -0
|
@@ -16,14 +16,39 @@ class ObservableDict(UserDict):
|
|
|
16
16
|
def __init__(self,
|
|
17
17
|
obj: Iterable | Mapping | None = None, *,
|
|
18
18
|
on_change: Callable[[Self], None] | None = None,
|
|
19
|
+
obsdict: dict | None = None,
|
|
19
20
|
validate: bool = False,
|
|
20
21
|
**kwargs):
|
|
22
|
+
"""
|
|
23
|
+
Initializes a new instance of the class with optional data and settings for
|
|
24
|
+
notifications and validation.
|
|
25
|
+
|
|
26
|
+
:param obj: An optional iterable or mapping containing initial data for the
|
|
27
|
+
instance. Defaults to None.
|
|
28
|
+
:type obj: Iterable | Mapping | None
|
|
29
|
+
:param on_change: A callable function that will be invoked when a change is made
|
|
30
|
+
to the instance. The function is passed the instance itself as an argument.
|
|
31
|
+
Defaults to None.
|
|
32
|
+
:type on_change: Callable[[Self], None] | None
|
|
33
|
+
:param obsdict: This is used in conjunction with the method _as_dict to serialize
|
|
34
|
+
the instance's data to JSON and back. It preserves the dataclasses also of the keys.
|
|
35
|
+
*NOTE": It should never be used directly – it's reserved for the @serializer decorator.
|
|
36
|
+
:type obsdict: dict | None
|
|
37
|
+
:param validate: A boolean flag indicating whether to enforce validation checks
|
|
38
|
+
on the data. Defaults to False.
|
|
39
|
+
:type validate: bool
|
|
40
|
+
:param kwargs: Additional keyword arguments forwarded to the superclass
|
|
41
|
+
initializer.
|
|
42
|
+
"""
|
|
21
43
|
self.__on_change = on_change
|
|
22
44
|
self._changeset = {}
|
|
23
45
|
if obj:
|
|
24
46
|
super().__init__(obj, **kwargs)
|
|
25
47
|
else:
|
|
26
48
|
super().__init__(**kwargs)
|
|
49
|
+
if obsdict:
|
|
50
|
+
for item in obsdict:
|
|
51
|
+
self[item['key']] = item['val']
|
|
27
52
|
|
|
28
53
|
def __setitem__(self, key, value):
|
|
29
54
|
if key in self.data:
|
|
@@ -48,8 +73,7 @@ class ObservableDict(UserDict):
|
|
|
48
73
|
self.__on_change = on_change
|
|
49
74
|
|
|
50
75
|
def _as_dict(self):
|
|
51
|
-
|
|
52
|
-
return {str(key): val for key, val in self.data.items()}
|
|
76
|
+
return {'obsdict': [{'key': key, 'val': val} for key, val in self.data.items()]}
|
|
53
77
|
|
|
54
78
|
def clear_changeset(self):
|
|
55
79
|
self._changeset = {}
|
oldaplib/src/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
1
|
+
__version__ = "0.3.1"
|
|
@@ -24,6 +24,6 @@ class TestObservableDict(unittest.TestCase):
|
|
|
24
24
|
def test_json(self):
|
|
25
25
|
obs = ObservableDict({Iri('http://gaga.com/a'): 1, Iri('http://gaga.com/b'): 2, Iri('http://gaga.com/c'): 3, Iri('http://gaga.com/d'): 4})
|
|
26
26
|
jsonstr = json.dumps(obs, default=serializer.encoder_default)
|
|
27
|
-
print(jsonstr)
|
|
28
27
|
obs2 = json.loads(jsonstr, object_hook=serializer.decoder_hook)
|
|
28
|
+
pass
|
|
29
29
|
self.assertEqual(obs2, {Iri('http://gaga.com/a'): 1, Iri('http://gaga.com/b'): 2, Iri('http://gaga.com/c'): 3, Iri('http://gaga.com/d'): 4})
|
|
@@ -45,7 +45,7 @@ oldaplib/src/helpers/irincname.py,sha256=0phRZDu8Tw0tT_pcKrdQVFjcvOCPhS3teNp_tbz
|
|
|
45
45
|
oldaplib/src/helpers/json_encoder.py,sha256=c78h9uf58zfLaK8X7S1KCK4otY3iEltGnPBy_5ryiCk,2135
|
|
46
46
|
oldaplib/src/helpers/langstring.py,sha256=0nQT_63tsZ67YiSgB3R6slb-jzxetWQbpFUWjmAubf0,30170
|
|
47
47
|
oldaplib/src/helpers/numeric.py,sha256=swRKU51zbwss9UDGTC6FzhTTPK_BVfy5On0KCK-zZnQ,966
|
|
48
|
-
oldaplib/src/helpers/observable_dict.py,sha256=
|
|
48
|
+
oldaplib/src/helpers/observable_dict.py,sha256=Nf-0kWg93oz0PbYNpnK1Iinuw0yJQ_GbYU0BnOviLq4,3074
|
|
49
49
|
oldaplib/src/helpers/observable_set.py,sha256=NKn4JU1wDU-Yp7usbD_rJaYjoD-L7x4dq5x3ra2NSdk,11289
|
|
50
50
|
oldaplib/src/helpers/oldaperror.py,sha256=2gKgV8FYiEjbcox1KN1PlOIPY4KclxVTnCIOQ6Ivvc0,1321
|
|
51
51
|
oldaplib/src/helpers/query_processor.py,sha256=r01_tndB4h6RAeJ2IN3jpz5efv8rSCx1MYAz6DNCQ2Q,10145
|
|
@@ -68,7 +68,7 @@ oldaplib/src/propertyclass.py,sha256=fu8pHPgKQJuNYrVcTPkIrX2tCHmcTIFG09KNtbLTj44
|
|
|
68
68
|
oldaplib/src/resourceclass.py,sha256=6SFF26TxJEmeltr7Qwl7zje3ApWt0h7LcaNVxjFwujg,101408
|
|
69
69
|
oldaplib/src/user.py,sha256=Z4GXPRkaHXx3glUpPXQdFqYMxQPOuqayDwkTAE5RGjU,48820
|
|
70
70
|
oldaplib/src/userdataclass.py,sha256=FbZkcRt0pKbOeqsZ7HbpwoKE-XPWH2AqpHG1GcsrBPo,12364
|
|
71
|
-
oldaplib/src/version.py,sha256=
|
|
71
|
+
oldaplib/src/version.py,sha256=v-ExhFzOD_GemLcOptv2ZODgnklv9iqEEospk_bU1_w,21
|
|
72
72
|
oldaplib/src/xsd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
73
|
oldaplib/src/xsd/floatingpoint.py,sha256=rDReKqh0mXyc4F5wslgTUxbeGf3-PGERyughj5_62YI,8852
|
|
74
74
|
oldaplib/src/xsd/iri.py,sha256=tXOuDASdQ6k9KKp2wTO8H4K8yb-_o8jFPanua7wCHog,8269
|
|
@@ -124,7 +124,7 @@ oldaplib/test/test_in_project.py,sha256=DYT-guwRQ9crnfEt7cQZxoEMxThin7QeymNce3ja
|
|
|
124
124
|
oldaplib/test/test_langstring.py,sha256=37BeKiQzj63G-SyS_paK_SEG7ulRbGrE89Mz40UB_bE,15146
|
|
125
125
|
oldaplib/test/test_language_in.py,sha256=ELqHO-YIsZSCPF3E3rWde4J7rERL7En7sV_pzQ00zgs,8826
|
|
126
126
|
oldaplib/test/test_objectfactory.py,sha256=F53k5wvpj8rFF8Mn9WOjMRcbTPEqqE0XHm7Zmm7r5go,30740
|
|
127
|
-
oldaplib/test/test_observable_dict.py,sha256=
|
|
127
|
+
oldaplib/test/test_observable_dict.py,sha256=LZML4I4RwR9EBrssHou0_c-J9m6Zju7nFl7h8JUu6yc,1048
|
|
128
128
|
oldaplib/test/test_observable_set.py,sha256=JWZSoAsr8XIEBXPVgSVJjQQEEc8uSAme5IrFYLYVVXw,6313
|
|
129
129
|
oldaplib/test/test_oldaplist.py,sha256=NNYtaqFrjs8FhUWujM5C52HmXUyaF8ct1CflFUK1zBM,20060
|
|
130
130
|
oldaplib/test/test_oldaplist_helpers.py,sha256=vJkA_Txhdk4oIwo2YK566yOte2Z6MQkshxPzCAg6k3I,24439
|
|
@@ -154,6 +154,6 @@ oldaplib/testdata/source_type.yaml,sha256=dSihKikw3O-IlGf6anj5KWMoBYLaweLVF1Zojm
|
|
|
154
154
|
oldaplib/testdata/test_move_left_of_toL.yaml,sha256=2m1OSQrQFlsCQxeJrjzBAO74LMprNDo_HuyrYGsOeXI,787
|
|
155
155
|
oldaplib/testdata/testlist.yaml,sha256=AT11nXEG81Sfyb-tr1gQV0H_dZBrOCcFuHf7YtL8P2g,1994
|
|
156
156
|
oldaplib/testit.http,sha256=qW7mnr6aNLXFG6lQdLgyhXILOPN6qc5iFVZclLyVvkY,303
|
|
157
|
-
oldaplib-0.3.
|
|
158
|
-
oldaplib-0.3.
|
|
159
|
-
oldaplib-0.3.
|
|
157
|
+
oldaplib-0.3.1.dist-info/METADATA,sha256=oyjJ9ghRAsxaKf5hTuG9cjuzd7EJ3ZhRtOzpWD4cfLU,2803
|
|
158
|
+
oldaplib-0.3.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
159
|
+
oldaplib-0.3.1.dist-info/RECORD,,
|
|
File without changes
|