moat-kv 0.71.0__py3-none-any.whl → 0.71.7__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.
Files changed (178) hide show
  1. moat/kv/__init__.py +6 -7
  2. moat/kv/_cfg.yaml +3 -2
  3. moat/kv/actor/__init__.py +2 -1
  4. moat/kv/actor/deletor.py +4 -1
  5. moat/kv/auth/__init__.py +12 -13
  6. moat/kv/auth/_test.py +4 -1
  7. moat/kv/auth/password.py +11 -7
  8. moat/kv/backend/mqtt.py +4 -5
  9. moat/kv/client.py +20 -39
  10. moat/kv/code.py +3 -3
  11. moat/kv/command/data.py +4 -3
  12. moat/kv/command/dump/__init__.py +36 -34
  13. moat/kv/command/internal.py +2 -3
  14. moat/kv/command/job.py +1 -2
  15. moat/kv/command/type.py +3 -6
  16. moat/kv/data.py +9 -8
  17. moat/kv/errors.py +16 -8
  18. moat/kv/mock/__init__.py +2 -12
  19. moat/kv/model.py +29 -33
  20. moat/kv/obj/__init__.py +3 -3
  21. moat/kv/obj/command.py +3 -3
  22. moat/kv/runner.py +4 -5
  23. moat/kv/server.py +106 -126
  24. moat/kv/types.py +10 -12
  25. {moat_kv-0.71.0.dist-info → moat_kv-0.71.7.dist-info}/METADATA +6 -2
  26. moat_kv-0.71.7.dist-info/RECORD +47 -0
  27. {moat_kv-0.71.0.dist-info → moat_kv-0.71.7.dist-info}/WHEEL +1 -1
  28. moat_kv-0.71.7.dist-info/licenses/LICENSE +3 -0
  29. moat_kv-0.71.7.dist-info/licenses/LICENSE.APACHE2 +202 -0
  30. moat_kv-0.71.7.dist-info/licenses/LICENSE.MIT +20 -0
  31. moat_kv-0.71.7.dist-info/top_level.txt +1 -0
  32. build/lib/docs/source/conf.py +0 -201
  33. build/lib/examples/pathify.py +0 -45
  34. build/lib/moat/kv/__init__.py +0 -19
  35. build/lib/moat/kv/_cfg.yaml +0 -93
  36. build/lib/moat/kv/_main.py +0 -91
  37. build/lib/moat/kv/actor/__init__.py +0 -98
  38. build/lib/moat/kv/actor/deletor.py +0 -139
  39. build/lib/moat/kv/auth/__init__.py +0 -444
  40. build/lib/moat/kv/auth/_test.py +0 -166
  41. build/lib/moat/kv/auth/password.py +0 -234
  42. build/lib/moat/kv/auth/root.py +0 -58
  43. build/lib/moat/kv/backend/__init__.py +0 -67
  44. build/lib/moat/kv/backend/mqtt.py +0 -71
  45. build/lib/moat/kv/client.py +0 -1025
  46. build/lib/moat/kv/code.py +0 -236
  47. build/lib/moat/kv/codec.py +0 -11
  48. build/lib/moat/kv/command/__init__.py +0 -1
  49. build/lib/moat/kv/command/acl.py +0 -180
  50. build/lib/moat/kv/command/auth.py +0 -261
  51. build/lib/moat/kv/command/code.py +0 -293
  52. build/lib/moat/kv/command/codec.py +0 -186
  53. build/lib/moat/kv/command/data.py +0 -265
  54. build/lib/moat/kv/command/dump/__init__.py +0 -143
  55. build/lib/moat/kv/command/error.py +0 -149
  56. build/lib/moat/kv/command/internal.py +0 -248
  57. build/lib/moat/kv/command/job.py +0 -433
  58. build/lib/moat/kv/command/log.py +0 -53
  59. build/lib/moat/kv/command/server.py +0 -114
  60. build/lib/moat/kv/command/type.py +0 -201
  61. build/lib/moat/kv/config.py +0 -46
  62. build/lib/moat/kv/data.py +0 -216
  63. build/lib/moat/kv/errors.py +0 -561
  64. build/lib/moat/kv/exceptions.py +0 -126
  65. build/lib/moat/kv/mock/__init__.py +0 -101
  66. build/lib/moat/kv/mock/mqtt.py +0 -159
  67. build/lib/moat/kv/mock/tracer.py +0 -63
  68. build/lib/moat/kv/model.py +0 -1069
  69. build/lib/moat/kv/obj/__init__.py +0 -646
  70. build/lib/moat/kv/obj/command.py +0 -241
  71. build/lib/moat/kv/runner.py +0 -1347
  72. build/lib/moat/kv/server.py +0 -2809
  73. build/lib/moat/kv/types.py +0 -513
  74. ci/rtd-requirements.txt +0 -4
  75. ci/test-requirements.txt +0 -7
  76. ci/travis.sh +0 -96
  77. debian/.gitignore +0 -7
  78. debian/changelog +0 -1435
  79. debian/control +0 -43
  80. debian/moat-kv/usr/lib/python3/dist-packages/docs/source/conf.py +0 -201
  81. debian/moat-kv/usr/lib/python3/dist-packages/examples/pathify.py +0 -45
  82. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/__init__.py +0 -19
  83. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_cfg.yaml +0 -93
  84. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_main.py +0 -91
  85. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/__init__.py +0 -98
  86. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/deletor.py +0 -139
  87. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/__init__.py +0 -444
  88. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/_test.py +0 -166
  89. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/password.py +0 -234
  90. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/root.py +0 -58
  91. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/__init__.py +0 -67
  92. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/mqtt.py +0 -71
  93. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/client.py +0 -1025
  94. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/code.py +0 -236
  95. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/codec.py +0 -11
  96. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/__init__.py +0 -1
  97. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/acl.py +0 -180
  98. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/auth.py +0 -261
  99. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/code.py +0 -293
  100. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/codec.py +0 -186
  101. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/data.py +0 -265
  102. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/dump/__init__.py +0 -143
  103. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/error.py +0 -149
  104. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/internal.py +0 -248
  105. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/job.py +0 -433
  106. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/log.py +0 -53
  107. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/server.py +0 -114
  108. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/type.py +0 -201
  109. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/config.py +0 -46
  110. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/data.py +0 -216
  111. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/errors.py +0 -561
  112. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/exceptions.py +0 -126
  113. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/__init__.py +0 -101
  114. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/mqtt.py +0 -159
  115. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/tracer.py +0 -63
  116. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/model.py +0 -1069
  117. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/__init__.py +0 -646
  118. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/command.py +0 -241
  119. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/runner.py +0 -1347
  120. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/server.py +0 -2809
  121. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/types.py +0 -513
  122. debian/moat-kv.postinst +0 -3
  123. debian/rules +0 -20
  124. debian/source/format +0 -1
  125. debian/watch +0 -4
  126. docs/Makefile +0 -20
  127. docs/make.bat +0 -36
  128. docs/source/TODO.rst +0 -61
  129. docs/source/_static/.gitkeep +0 -0
  130. docs/source/acls.rst +0 -80
  131. docs/source/auth.rst +0 -84
  132. docs/source/client_protocol.rst +0 -456
  133. docs/source/code.rst +0 -341
  134. docs/source/command_line.rst +0 -1187
  135. docs/source/common_protocol.rst +0 -47
  136. docs/source/conf.py +0 -201
  137. docs/source/debugging.rst +0 -70
  138. docs/source/extend.rst +0 -37
  139. docs/source/history.rst +0 -36
  140. docs/source/index.rst +0 -75
  141. docs/source/model.rst +0 -54
  142. docs/source/overview.rst +0 -83
  143. docs/source/related.rst +0 -89
  144. docs/source/server_protocol.rst +0 -450
  145. docs/source/startup.rst +0 -31
  146. docs/source/translator.rst +0 -244
  147. docs/source/tutorial.rst +0 -711
  148. docs/source/v3.rst +0 -168
  149. examples/code/transform.scale.yml +0 -21
  150. examples/code/transform.switch.yml +0 -82
  151. examples/code/transform.timeslot.yml +0 -63
  152. examples/pathify.py +0 -45
  153. moat/kv/codec.py +0 -11
  154. moat_kv-0.71.0.dist-info/RECORD +0 -188
  155. moat_kv-0.71.0.dist-info/top_level.txt +0 -9
  156. scripts/current +0 -15
  157. scripts/env +0 -8
  158. scripts/init +0 -39
  159. scripts/recover +0 -17
  160. scripts/rotate +0 -33
  161. scripts/run +0 -29
  162. scripts/run-all +0 -10
  163. scripts/run-any +0 -10
  164. scripts/run-single +0 -15
  165. scripts/success +0 -4
  166. systemd/moat-kv-recover.service +0 -21
  167. systemd/moat-kv-rotate.service +0 -20
  168. systemd/moat-kv-rotate.timer +0 -10
  169. systemd/moat-kv-run-all.service +0 -26
  170. systemd/moat-kv-run-all@.service +0 -25
  171. systemd/moat-kv-run-any.service +0 -26
  172. systemd/moat-kv-run-any@.service +0 -25
  173. systemd/moat-kv-run-single.service +0 -26
  174. systemd/moat-kv-run-single@.service +0 -25
  175. systemd/moat-kv.service +0 -27
  176. systemd/postinst +0 -7
  177. systemd/sysusers +0 -3
  178. {moat_kv-0.71.0.dist-info → moat_kv-0.71.7.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,513 +0,0 @@
1
- from __future__ import annotations
2
- import logging
3
- import weakref
4
-
5
- import jsonschema
6
- from moat.util import NotGiven, P, Path, make_proc, singleton
7
-
8
- from .exceptions import ACLError, ClientError
9
- from .model import Entry
10
-
11
- logger = logging.getLogger(__name__)
12
-
13
- # TYPES
14
-
15
-
16
- class MetaEntry(Entry):
17
- def __init__(self, *a, **k):
18
- super().__init__(*a, **k)
19
- self._metaroot = self.parent._metaroot
20
-
21
- @property
22
- def metaroot(self):
23
- "Stores a link to the meta root because some do need it."
24
- return self._metaroot()
25
-
26
-
27
- class TypeEntry(Entry):
28
- """I am a type-checking node."""
29
-
30
- _code = None
31
- _schema = None
32
-
33
- def check_value(self, value, entry=None, **kv):
34
- self.parent.check_value(value, entry=entry, **kv)
35
- if self._schema is not None:
36
- jsonschema.validate(instance=value, schema=self._schema)
37
- if self._code is not None:
38
- self._code(value, entry=entry, data=self._data, **kv)
39
-
40
- async def set(self, value):
41
- code = None
42
- schema = None
43
- if value is not NotGiven and (
44
- value.get("code", None) is not None or value.get("schema", None) is not None
45
- ):
46
- schema = value.get("schema", None)
47
- if value.get("code", None) is None:
48
- code = None
49
- else:
50
- code = make_proc(value.code, ("value",), self.path)
51
- if len(value.good) < 2:
52
- raise RuntimeError("Must have check-good values")
53
- if not value.bad:
54
- raise RuntimeError("Must have check-bad values")
55
- for v in value["good"]:
56
- self.parent.check_value(v)
57
- try:
58
- if schema is not None:
59
- jsonschema.validate(instance=v, schema=schema)
60
- if code is not None:
61
- code(v, entry=None)
62
- except Exception:
63
- raise ValueError(f"failed on good value {v!r}")
64
- for v in value["bad"]:
65
- self.parent.check_value(v)
66
- try:
67
- if schema is not None:
68
- jsonschema.validate(instance=v, schema=schema)
69
- if code is not None:
70
- code(v, entry=None)
71
- except Exception:
72
- pass
73
- else:
74
- raise ValueError(f"did not fail on {v!r}")
75
-
76
- await super().set(value)
77
- self._code = code
78
- self._schema = schema
79
-
80
-
81
- TypeEntry.SUBTYPE = TypeEntry
82
-
83
-
84
- class TypeRoot(Entry):
85
- """I am the root of MoaT-KV's type hierarchy."""
86
-
87
- SUBTYPE = TypeEntry
88
-
89
- async def set(self, value):
90
- if value is not NotGiven:
91
- raise ValueError("This node can't have data.")
92
-
93
- def check_value(self, value, entry=None, **kv):
94
- pass
95
-
96
-
97
- # MATCH (for types)
98
-
99
-
100
- class MatchEntry(MetaEntry):
101
- """I represent a match from a path to a type.
102
-
103
- My data requires a "type" attribute that's a path in the "type"
104
- hierarchy that's next to my MatchRoot.
105
- """
106
-
107
- async def set(self, value):
108
- if value is NotGiven:
109
- pass
110
- elif isinstance(value.type, str):
111
- value.type = P(value.type)
112
- elif not isinstance(value.type, (Path, list, tuple)):
113
- raise ValueError("Type of %r is not a list" % (value.type,))
114
- try:
115
- self.metaroot["type"].follow(value.type, create=False)
116
- except KeyError:
117
- logger.exception("Type %r doesn't exist", value.type)
118
- raise ClientError("This type does not exist")
119
- # crashes if nonexistent
120
- await super().set(value)
121
-
122
-
123
- MatchEntry.SUBTYPE = MatchEntry
124
-
125
-
126
- class NodeFinder:
127
- """A generic object that can walk down a possibly-wildcard-equipped path.
128
-
129
- Example: given a path `one.two.three` and a root `bar` with subtree `bar.#.three`,
130
- `NodeFinder(bar).step(one).step(two).step(three)` will return the node
131
- at `bar.#.three` (assuming that nothing more specific hangs off `bar`).
132
- """
133
-
134
- def __init__(self, meta):
135
- if isinstance(meta, list):
136
- self.steps = meta
137
- else:
138
- self.steps = ((meta, False),)
139
-
140
- def step(self, name, new=False):
141
- steps = []
142
- for node, keep in self.steps:
143
- if name in node:
144
- steps.append((node[name], False))
145
- if name is None:
146
- continue
147
- if "+" in node:
148
- steps.append((node["+"], False))
149
- if "#" in node:
150
- steps.append((node["#"], True))
151
- if keep:
152
- steps.append((node, True))
153
- # Nodes found with '#' stay on the list
154
- # so that they can match multiple entries.
155
- # if not steps:
156
- # raise KeyError(name)
157
- if new:
158
- return type(self)(steps, **self.copy_args)
159
- else:
160
- self.steps = steps
161
- return self
162
-
163
- @property
164
- def copy_args(self):
165
- return {}
166
-
167
- @property
168
- def result(self):
169
- for node, _keep in self.steps:
170
- if node._data is not NotGiven:
171
- return node
172
- return None
173
-
174
-
175
- class ACLFinder(NodeFinder):
176
- """A NodeFinder which expects ACL strings as elements"""
177
-
178
- _block = ""
179
-
180
- @property
181
- def copy_args(self):
182
- return {"blocked": self._block}
183
-
184
- def __init__(self, acl, blocked=None):
185
- if isinstance(acl, ACLFinder):
186
- if blocked is None:
187
- blocked = acl._block
188
- acl = acl.steps
189
- super().__init__(acl)
190
- if blocked is not None:
191
- self._block = blocked
192
-
193
- def allows(self, x):
194
- if x in self._block:
195
- return False
196
-
197
- r = self.result
198
- if r is None:
199
- return True
200
- return x in r.data
201
-
202
- def block(self, c):
203
- if c not in self._block:
204
- self._block += c
205
-
206
- def check(self, x):
207
- if not self.allows(x):
208
- raise ACLError(self.result, x)
209
-
210
-
211
- class ACLStepper(ACLFinder):
212
- """An ACLFinder which returns a copy of itself at every `step`."""
213
-
214
- def step(self, name, new=True):
215
- return super().step(name, new=new)
216
-
217
-
218
- @singleton
219
- class NullACL(ACLStepper):
220
- """This singleton represents an ACL that never checks anything."""
221
-
222
- result = "-"
223
-
224
- def __init__(self): # pylint: disable=super-init-not-called
225
- pass
226
-
227
- def allows(self, x):
228
- return x != "a"
229
-
230
- def check(self, x):
231
- return
232
-
233
- def block(self, c):
234
- pass
235
-
236
- def step(self, name, new=None):
237
- return self
238
-
239
-
240
- class MetaPathEntry(MetaEntry):
241
- def _find_node(self, entry):
242
- """Search for the most-specific match.
243
-
244
- Match entries whose values are missing are not considered.
245
- """
246
- f = NodeFinder(self)
247
- for n in entry.path:
248
- f.step(n)
249
- return f.result
250
-
251
-
252
- class MatchRoot(MetaPathEntry):
253
- """I am the root of MoaT-KV's type hierarchy."""
254
-
255
- SUBTYPE = MatchEntry
256
-
257
- async def set(self, value):
258
- if value is not None:
259
- raise ValueError("This node can't have data.")
260
-
261
- def check_value(self, value, entry, **kv):
262
- """Check this value for this entry against my match hierarchy"""
263
- match = self._find_node(entry)
264
- if match is None:
265
- return
266
- typ = self.parent["type"].follow(match._data["type"])
267
- return typ.check_value(value, entry=entry, match=match, **kv)
268
-
269
-
270
- class CodecEntry(Entry):
271
- """I am a codec."""
272
-
273
- _enc = None
274
- _dec = None
275
-
276
- def enc_value(self, value, entry=None, **kv):
277
- if self._enc is not None:
278
- try:
279
- value = self._enc(value, entry=entry, data=self._data, **kv)
280
- except TypeError:
281
- if value is not None:
282
- raise
283
- return value
284
-
285
- def dec_value(self, value, entry=None, **kv):
286
- if self._dec is not None:
287
- try:
288
- value = self._dec(value, entry=entry, data=self._data, **kv)
289
- except TypeError:
290
- if value is not None:
291
- raise
292
- return value
293
-
294
- async def set(self, value):
295
- enc = None
296
- dec = None
297
- if value is not None and value.decode is not None:
298
- if not value["in"]:
299
- raise RuntimeError("Must have tests for decoding")
300
- dec = make_proc(value.decode, ("value",), self.path)
301
- for v, w in value["in"]:
302
- try:
303
- r = dec(v)
304
- except Exception as exc:
305
- raise ValueError(
306
- f"failed decoder at {self.path} on {v!r} with {exc!r}",
307
- ) from exc
308
- else:
309
- if r != w:
310
- raise ValueError(f"Decoding at {self.path}: {v!r} got {r!r}, not {w!r}")
311
-
312
- if value is not None and value.encode is not None:
313
- if not value["out"]:
314
- raise RuntimeError("Must have tests for encoding")
315
- enc = make_proc(value.encode, ("value",), self.path)
316
- for v, w in value["out"]:
317
- try:
318
- r = enc(v)
319
- except Exception as exc:
320
- raise ValueError(
321
- f"failed encoder at {self.path} on {v!r} with {exc!r}",
322
- ) from exc
323
- else:
324
- if r != w:
325
- raise ValueError(f"Encoding at {self.path}: {v!r} got {r!r}, not {w!r}")
326
-
327
- await super().set(value)
328
- self._enc = enc
329
- self._dec = dec
330
-
331
-
332
- CodecEntry.SUBTYPE = CodecEntry
333
-
334
-
335
- class CodecRoot(Entry):
336
- """I am the root of MoaT-KV's codec hierarchy."""
337
-
338
- SUBTYPE = CodecEntry
339
-
340
- async def set(self, value):
341
- if value is not None:
342
- raise ValueError("This node can't have data.")
343
-
344
- def check_value(self, value, entry=None, **kv):
345
- pass
346
-
347
-
348
- # CONV (for codecs)
349
-
350
-
351
- class ConvEntry(MetaEntry):
352
- """I represent a converter from a path to a type.
353
-
354
- My data requires a "codec" attribute that's a path in the "codecs"
355
- hierarchy that's next to my Root.
356
- """
357
-
358
- async def set(self, value):
359
- if value is not NotGiven:
360
- # can't run a nonexistent value through a codec
361
-
362
- if not hasattr(value, "codec"):
363
- raise ValueError("Duh? " + repr(value))
364
- if isinstance(value.codec, str):
365
- value.codec = P(value.codec)
366
- elif not isinstance(value.codec, (Path, list, tuple)):
367
- raise ValueError("Codec %r is not a list" % (value.codec,))
368
- try:
369
- self.metaroot["codec"].follow(value.codec, create=False)
370
- except KeyError:
371
- logger.warning("Codec %r does not exist (yet?)", value.codec)
372
- # raise ClientError("This codec does not exist")
373
- # don't raise here
374
- await super().set(value)
375
-
376
-
377
- ConvEntry.SUBTYPE = ConvEntry
378
-
379
-
380
- class ConvNull:
381
- """I am a dummy translator"""
382
-
383
- @staticmethod
384
- def enc_value(value, **_kw):
385
- return value
386
-
387
- @staticmethod
388
- def dec_value(value, **_kw):
389
- return value
390
-
391
-
392
- ConvNull = ConvNull()
393
-
394
-
395
- class ConvName(MetaPathEntry):
396
- """I am a named tree for conversion entries."""
397
-
398
- SUBTYPE = ConvEntry
399
-
400
- async def set(self, value):
401
- if value is not None:
402
- raise ValueError("This node can't have data.")
403
-
404
- def enc_value(self, value, entry, **kv):
405
- """Check this value for this entry against my converter hierarchy"""
406
- conv = self._find_node(entry)
407
- if conv is None:
408
- return value
409
- codec = self.metaroot["codec"].follow(conv._data["codec"])
410
- return codec.enc_value(value, entry=entry, conv=conv, **kv)
411
-
412
- def dec_value(self, value, entry, **kv):
413
- """Check this value for this entry against my converter hierarchy"""
414
- conv = self._find_node(entry)
415
- if conv is None:
416
- return value
417
- codec = self.metaroot["codec"].follow(conv._data["codec"])
418
- return codec.dec_value(value, entry=entry, conv=conv, **kv)
419
-
420
-
421
- class ConvRoot(MetaEntry):
422
- SUBTYPE = ConvName
423
-
424
- async def set(self, value):
425
- if value is not None:
426
- raise ValueError("This node can't have data.")
427
-
428
-
429
- class AclEntry(MetaPathEntry):
430
- """I represent an ACL.
431
-
432
- My data must be a string of ACLish characters.
433
- """
434
-
435
- async def set(self, value):
436
- if value is NotGiven:
437
- pass
438
- elif not isinstance(value, str):
439
- raise ValueError("ACL is not a string")
440
- await super().set(value)
441
-
442
-
443
- AclEntry.SUBTYPE = AclEntry
444
-
445
-
446
- class AclName(AclEntry):
447
- """I am a named tree for ACL entries."""
448
-
449
- SUBTYPE = AclEntry
450
-
451
- async def check(self, entry, typ):
452
- acl = self._find_node(entry)
453
- if acl is None:
454
- return None
455
- return typ in acl.value
456
-
457
-
458
- class AclRoot(MetaEntry):
459
- SUBTYPE = AclName
460
-
461
- async def set(self, value):
462
- if value is not None:
463
- raise ValueError("This node can't have data.")
464
-
465
-
466
- class DelRoot(Entry):
467
- SUBTYPE = None
468
-
469
- async def set(self, value):
470
- await super().set(value)
471
- await self.root.server.del_check(value)
472
-
473
-
474
- class ActorRoot(Entry):
475
- SUBTYPE = None
476
- SUBTYPES = {"del": DelRoot}
477
-
478
-
479
- # ROOT
480
-
481
-
482
- class MetaRootEntry(Entry): # not MetaEntry
483
- """I am the special node off the MoaT-KV root that's named ``None``."""
484
-
485
- SUBTYPES = {
486
- "type": TypeRoot,
487
- "match": MatchRoot,
488
- "acl": AclRoot,
489
- "codec": CodecRoot,
490
- "conv": ConvRoot,
491
- "actor": ActorRoot,
492
- }
493
-
494
- def __init__(self, *a, **k):
495
- super().__init__(*a, **k)
496
- self._metaroot = weakref.ref(self)
497
-
498
-
499
- Entry.SUBTYPES[None] = MetaRootEntry
500
-
501
-
502
- class RootEntry(Entry):
503
- """I am the root of the MoaT-KV data tree."""
504
-
505
- def __init__(self, server, *a, **k):
506
- super().__init__("ROOT", None, *a, **k)
507
- self._server = weakref.ref(server)
508
-
509
- @property
510
- def server(self):
511
- return self._server()
512
-
513
- SUBTYPES = {None: MetaRootEntry}
debian/moat-kv.postinst DELETED
@@ -1,3 +0,0 @@
1
- #!/bin/sh
2
-
3
- /usr/lib/moat/kv/init
debian/rules DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/make -f
2
-
3
- # This file was automatically generated by stdeb 0.8.5 at
4
- # Sun, 21 Apr 2019 07:51:58 +0200
5
- export PYBUILD_NAME=moat-kv
6
- export LOG_CFG=$(shell pwd)/tests/logging.cfg
7
- export MSGPACK_PUREPYTHON=1
8
- %:
9
- dh $@ --with python3 --buildsystem=pybuild
10
-
11
- override_dh_install:
12
- dh_install
13
- $(MAKE) install PREFIX=debian/moat-kv
14
-
15
- override_dh_python3:
16
- dh_python3
17
- rm -f debian/moat-kv/usr/lib/python3/dist-packages/test.log
18
-
19
- override_dh_auto_test:
20
- : skip
debian/source/format DELETED
@@ -1 +0,0 @@
1
- 3.0 (quilt)
debian/watch DELETED
@@ -1,4 +0,0 @@
1
- # please also check http://pypi.debian.net/distkv/watch
2
- version=3
3
- opts=uversionmangle=s/(rc|a|b|c)/~$1/ \
4
- http://pypi.debian.net/distkv/distkv-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
docs/Makefile DELETED
@@ -1,20 +0,0 @@
1
- # Minimal makefile for Sphinx documentation
2
- #
3
-
4
- # You can set these variables from the command line.
5
- SPHINXOPTS =
6
- SPHINXBUILD = sphinx-build
7
- SPHINXPROJ = MoaT-KV
8
- SOURCEDIR = source
9
- BUILDDIR = build
10
-
11
- # Put it first so that "make" without argument is like "make help".
12
- help:
13
- @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
-
15
- .PHONY: help Makefile
16
-
17
- # Catch-all target: route all unknown targets to Sphinx using the new
18
- # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
- %: Makefile
20
- @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
docs/make.bat DELETED
@@ -1,36 +0,0 @@
1
- @ECHO OFF
2
-
3
- pushd %~dp0
4
-
5
- REM Command file for Sphinx documentation
6
-
7
- if "%SPHINXBUILD%" == "" (
8
- set SPHINXBUILD=sphinx-build
9
- )
10
- set SOURCEDIR=source
11
- set BUILDDIR=build
12
- set SPHINXPROJ=MoaT-KV
13
-
14
- if "%1" == "" goto help
15
-
16
- %SPHINXBUILD% >NUL 2>NUL
17
- if errorlevel 9009 (
18
- echo.
19
- echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
20
- echo.installed, then set the SPHINXBUILD environment variable to point
21
- echo.to the full path of the 'sphinx-build' executable. Alternatively you
22
- echo.may add the Sphinx directory to PATH.
23
- echo.
24
- echo.If you don't have Sphinx installed, grab it from
25
- echo.http://sphinx-doc.org/
26
- exit /b 1
27
- )
28
-
29
- %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30
- goto end
31
-
32
- :help
33
- %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34
-
35
- :end
36
- popd
docs/source/TODO.rst DELETED
@@ -1,61 +0,0 @@
1
- Open issues
2
- ===========
3
-
4
- * Exchange a version code on startup
5
-
6
- * CBOR
7
-
8
- * Ping: ignore messages with decreasing tock (per node)
9
-
10
- * chroot operation: add and test proper sub-roots, including auth and
11
- whatnot
12
-
13
- * We need path translation. Idea: store an extension element in the
14
- destination path, which would pick the appropriate parts from the
15
- source path when processed.
16
-
17
- 2-element tuples would probably work also, given that it's unlikely that
18
- people use complex elements in their path, but why limit ourselves?
19
-
20
- * ACLs for system data, i.e. those stored below ``None``.
21
-
22
- * after starting with initial data, wait until the Actor is up and we're
23
- synced to the other nodes
24
-
25
- * Teach the server to also run an executor (or two or three or …)
26
-
27
- * Rather than mangling split messages, use a MsgPack extension type.
28
-
29
- * AnyRunner: Do proper load balancing; the leader should be able to tell
30
- some other node to run a job if it's busy.
31
-
32
- * Keep an error index on the server? Something more general?
33
-
34
- * Restart code that's been changed (without waiting for restart/retry).
35
-
36
- * Use cryptography.hazmat.primitives.asymmetric.x25519 instead of
37
- Diffie-Hellman to send passwords to the server.
38
-
39
- * Implement a shared secret to sign server-to-server messages.
40
-
41
- * Runner: switch to monotonic time (except for target time!)
42
-
43
- * Error consolidation: if a conflict doesn't get resolved on its own, do it
44
- anyway when we are "it" next and >1 cycle has passed
45
-
46
- * Add a command to cleanly flush the server log and stop the server.
47
-
48
- * Test iterator on changed config entries
49
-
50
- * errors: better display
51
-
52
- * errors: manually acknowledge and delete them
53
-
54
- * errors: add a web service to monitor them?
55
-
56
- * Runner: store the number of active group members / actor config in the group
57
-
58
- * Restore passing positional parameters as keywords (to code entries)
59
-
60
- * Add a maintainer mode (user flag) that allows limited access when data is missing
61
-
File without changes