uiprotect 0.6.0__py3-none-any.whl → 0.7.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 uiprotect might be problematic. Click here for more details.
- uiprotect/data/base.py +29 -33
- {uiprotect-0.6.0.dist-info → uiprotect-0.7.0.dist-info}/METADATA +1 -1
- {uiprotect-0.6.0.dist-info → uiprotect-0.7.0.dist-info}/RECORD +6 -6
- {uiprotect-0.6.0.dist-info → uiprotect-0.7.0.dist-info}/LICENSE +0 -0
- {uiprotect-0.6.0.dist-info → uiprotect-0.7.0.dist-info}/WHEEL +0 -0
- {uiprotect-0.6.0.dist-info → uiprotect-0.7.0.dist-info}/entry_points.txt +0 -0
uiprotect/data/base.py
CHANGED
|
@@ -56,11 +56,10 @@ if TYPE_CHECKING:
|
|
|
56
56
|
from ..data.user import User
|
|
57
57
|
|
|
58
58
|
try:
|
|
59
|
-
from pydantic.v1.typing import DictStrAny
|
|
59
|
+
from pydantic.v1.typing import DictStrAny
|
|
60
60
|
except ImportError:
|
|
61
61
|
from pydantic.typing import ( # type: ignore[assignment, no-redef]
|
|
62
62
|
DictStrAny,
|
|
63
|
-
SetStr,
|
|
64
63
|
)
|
|
65
64
|
|
|
66
65
|
|
|
@@ -88,11 +87,8 @@ class ProtectBaseObject(BaseModel):
|
|
|
88
87
|
_api: ProtectApiClient | None = PrivateAttr(None)
|
|
89
88
|
|
|
90
89
|
_protect_objs: ClassVar[dict[str, type[ProtectBaseObject]] | None] = None
|
|
91
|
-
_protect_objs_set: ClassVar[SetStr | None] = None
|
|
92
90
|
_protect_lists: ClassVar[dict[str, type[ProtectBaseObject]] | None] = None
|
|
93
|
-
_protect_lists_set: ClassVar[SetStr | None] = None
|
|
94
91
|
_protect_dicts: ClassVar[dict[str, type[ProtectBaseObject]] | None] = None
|
|
95
|
-
_protect_dicts_set: ClassVar[SetStr | None] = None
|
|
96
92
|
_to_unifi_remaps: ClassVar[DictStrAny | None] = None
|
|
97
93
|
|
|
98
94
|
class Config:
|
|
@@ -192,6 +188,12 @@ class ProtectBaseObject(BaseModel):
|
|
|
192
188
|
"""
|
|
193
189
|
return {}
|
|
194
190
|
|
|
191
|
+
@classmethod
|
|
192
|
+
@cache
|
|
193
|
+
def _get_unifi_remaps_set(self) -> set[str]:
|
|
194
|
+
"""Helper method to get set of all child UFP objects."""
|
|
195
|
+
return set(self._get_unifi_remaps())
|
|
196
|
+
|
|
195
197
|
@classmethod
|
|
196
198
|
def _get_to_unifi_remaps(cls) -> dict[str, str]:
|
|
197
199
|
"""
|
|
@@ -231,55 +233,49 @@ class ProtectBaseObject(BaseModel):
|
|
|
231
233
|
pass
|
|
232
234
|
|
|
233
235
|
@classmethod
|
|
236
|
+
@cache
|
|
234
237
|
def _get_protect_objs(cls) -> dict[str, type[ProtectBaseObject]]:
|
|
235
238
|
"""Helper method to get all child UFP objects"""
|
|
236
|
-
if cls._protect_objs is
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
cls.
|
|
240
|
-
return cls._protect_objs # type: ignore[return-value]
|
|
239
|
+
if cls._protect_objs is None:
|
|
240
|
+
cls._set_protect_subtypes()
|
|
241
|
+
assert cls._protect_objs is not None
|
|
242
|
+
return cls._protect_objs
|
|
241
243
|
|
|
242
244
|
@classmethod
|
|
245
|
+
@cache
|
|
243
246
|
def _get_protect_objs_set(cls) -> set[str]:
|
|
244
247
|
"""Helper method to get all child UFP objects"""
|
|
245
|
-
|
|
246
|
-
cls._protect_objs_set = set(cls._get_protect_objs().keys())
|
|
247
|
-
|
|
248
|
-
return cls._protect_objs_set
|
|
248
|
+
return set(cls._get_protect_objs())
|
|
249
249
|
|
|
250
250
|
@classmethod
|
|
251
|
+
@cache
|
|
251
252
|
def _get_protect_lists(cls) -> dict[str, type[ProtectBaseObject]]:
|
|
252
253
|
"""Helper method to get all child of UFP objects (lists)"""
|
|
253
|
-
if cls._protect_lists is
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
cls.
|
|
257
|
-
return cls._protect_lists # type: ignore[return-value]
|
|
254
|
+
if cls._protect_lists is None:
|
|
255
|
+
cls._set_protect_subtypes()
|
|
256
|
+
assert cls._protect_lists is not None
|
|
257
|
+
return cls._protect_lists
|
|
258
258
|
|
|
259
259
|
@classmethod
|
|
260
|
+
@cache
|
|
260
261
|
def _get_protect_lists_set(cls) -> set[str]:
|
|
261
262
|
"""Helper method to get all child UFP objects"""
|
|
262
|
-
|
|
263
|
-
cls._protect_lists_set = set(cls._get_protect_lists().keys())
|
|
264
|
-
|
|
265
|
-
return cls._protect_lists_set
|
|
263
|
+
return set(cls._get_protect_lists())
|
|
266
264
|
|
|
267
265
|
@classmethod
|
|
266
|
+
@cache
|
|
268
267
|
def _get_protect_dicts(cls) -> dict[str, type[ProtectBaseObject]]:
|
|
269
268
|
"""Helper method to get all child of UFP objects (dicts)"""
|
|
270
|
-
if cls._protect_dicts is
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
cls.
|
|
274
|
-
return cls._protect_dicts # type: ignore[return-value]
|
|
269
|
+
if cls._protect_dicts is None:
|
|
270
|
+
cls._set_protect_subtypes()
|
|
271
|
+
assert cls._protect_dicts is not None
|
|
272
|
+
return cls._protect_dicts
|
|
275
273
|
|
|
276
274
|
@classmethod
|
|
275
|
+
@cache
|
|
277
276
|
def _get_protect_dicts_set(cls) -> set[str]:
|
|
278
277
|
"""Helper method to get all child UFP objects"""
|
|
279
|
-
|
|
280
|
-
cls._protect_dicts_set = set(cls._get_protect_dicts().keys())
|
|
281
|
-
|
|
282
|
-
return cls._protect_dicts_set
|
|
278
|
+
return set(cls._get_protect_dicts())
|
|
283
279
|
|
|
284
280
|
@classmethod
|
|
285
281
|
def _clean_protect_obj(
|
|
@@ -338,7 +334,7 @@ class ProtectBaseObject(BaseModel):
|
|
|
338
334
|
|
|
339
335
|
# remap keys that will not be converted correctly by snake_case convert
|
|
340
336
|
remaps = cls._get_unifi_remaps()
|
|
341
|
-
for from_key in
|
|
337
|
+
for from_key in cls._get_unifi_remaps_set().intersection(data):
|
|
342
338
|
data[remaps[from_key]] = data.pop(from_key)
|
|
343
339
|
|
|
344
340
|
# convert to snake_case and remove extra fields
|
|
@@ -14,7 +14,7 @@ uiprotect/cli/nvr.py,sha256=TwxEg2XT8jXAbOqv6gc7KFXELKadeItEDYweSL4_-e8,4260
|
|
|
14
14
|
uiprotect/cli/sensors.py,sha256=fQtcDJCVxs4VbAqcavgBy2ABiVxAW3GXtna6_XFBp2k,8153
|
|
15
15
|
uiprotect/cli/viewers.py,sha256=2cyrp104ffIvgT0wYGIO0G35QMkEbFe7fSVqLwDXQYQ,2171
|
|
16
16
|
uiprotect/data/__init__.py,sha256=OcfuJl2qXfHcj_mdnrHhzZ5tEIZrw8auziX5IE7dn-I,2938
|
|
17
|
-
uiprotect/data/base.py,sha256=
|
|
17
|
+
uiprotect/data/base.py,sha256=f032w_AnTT3Hd85eBVs2XdnyzHpckdCwiJrsMQyLsR8,37192
|
|
18
18
|
uiprotect/data/bootstrap.py,sha256=ibfCHqNhH44iw-JsuQs41zBCjb9ksSXz_QQq7qDbLsQ,21876
|
|
19
19
|
uiprotect/data/convert.py,sha256=rOQplUMIdTMD2SbAx_iI9BNPDscnhDvyRVLEMDhtADg,2047
|
|
20
20
|
uiprotect/data/devices.py,sha256=AsCQCoOpswdIU7X5ty1XhhOl2v6CkQCXu2Y-lIS_6_k,111712
|
|
@@ -30,8 +30,8 @@ uiprotect/test_util/__init__.py,sha256=d2g7afa0LSdixQ0kjEDYwafDFME_UlW2LzxpamZ2B
|
|
|
30
30
|
uiprotect/test_util/anonymize.py,sha256=f-8ijU-_y9r-uAbhIPn0f0I6hzJpAkvJzc8UpWihObI,8478
|
|
31
31
|
uiprotect/utils.py,sha256=gCLoZBQ94Yi9PqefiqTZK7WrvT3Byue79a4jvDc0k44,18226
|
|
32
32
|
uiprotect/websocket.py,sha256=iMTdchymaCgVHsmY1bRbxkcymqt6WQircIHYNxCu178,7289
|
|
33
|
-
uiprotect-0.
|
|
34
|
-
uiprotect-0.
|
|
35
|
-
uiprotect-0.
|
|
36
|
-
uiprotect-0.
|
|
37
|
-
uiprotect-0.
|
|
33
|
+
uiprotect-0.7.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
|
|
34
|
+
uiprotect-0.7.0.dist-info/METADATA,sha256=RDKJOvu9_P8mVZTKOBwzBBfZhxXdU_KdMHbUrMQEnZ4,10984
|
|
35
|
+
uiprotect-0.7.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
36
|
+
uiprotect-0.7.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
|
|
37
|
+
uiprotect-0.7.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|