uiprotect 0.4.1__py3-none-any.whl → 0.5.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/utils.py CHANGED
@@ -234,11 +234,11 @@ def convert_unifi_data(value: Any, field: ModelField) -> Any:
234
234
  return value
235
235
  if type_ == datetime:
236
236
  return from_js_time(value)
237
- if type_ in _CREATE_TYPES or (isclass(type_) and issubclass(type_, Enum)):
237
+ if type_ in _CREATE_TYPES or _is_enum_type(type_):
238
238
  # cannot do this check too soon because some types cannot be used in isinstance
239
239
  if isinstance(value, type_):
240
240
  return value
241
- # handle edge case for improperly formated UUIDs
241
+ # handle edge case for improperly formatted UUIDs
242
242
  # 00000000-0000-00 0- 000-000000000000
243
243
  if type_ == UUID and value == _BAD_UUID:
244
244
  value = "0" * 32
@@ -247,6 +247,12 @@ def convert_unifi_data(value: Any, field: ModelField) -> Any:
247
247
  return value
248
248
 
249
249
 
250
+ @lru_cache
251
+ def _is_enum_type(type_: Any) -> bool:
252
+ """Checks if type is an Enum."""
253
+ return isclass(type_) and issubclass(type_, Enum)
254
+
255
+
250
256
  def serialize_unifi_obj(value: Any, levels: int = -1) -> Any:
251
257
  """Serializes UFP data"""
252
258
  if unifi_dict := getattr(value, "unifi_dict", None):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: Python API for Unifi Protect (Unofficial)
5
5
  Home-page: https://github.com/uilibs/uiprotect
6
6
  License: MIT
@@ -28,10 +28,10 @@ uiprotect/release_cache.json,sha256=NamnSFy78hOWY0DPO87J9ELFCAN6NnVquv8gQO75ZG4,
28
28
  uiprotect/stream.py,sha256=V4aJfVWpSUsWE1PQrXH8F7obQQi1ukPAZ7PzwABjt0I,4942
29
29
  uiprotect/test_util/__init__.py,sha256=sSEXu6_pwdYNQSCYtftpX1Dy1S8XYOvhrpECYRxeKJE,18596
30
30
  uiprotect/test_util/anonymize.py,sha256=AGYELhDC4BrdK0deI6zh5jFp3SuM_HvAWLeoxFHSiwg,8486
31
- uiprotect/utils.py,sha256=xP8t0wEBIGS___LUYRNnQuXvUbjKDbsOnnSwWDzphSw,18124
31
+ uiprotect/utils.py,sha256=1HB-rtzdTxsRzEY_vnzdJZOzyruci7lOkQDfr8D1L_8,18244
32
32
  uiprotect/websocket.py,sha256=iMTdchymaCgVHsmY1bRbxkcymqt6WQircIHYNxCu178,7289
33
- uiprotect-0.4.1.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
- uiprotect-0.4.1.dist-info/METADATA,sha256=EOocaNozRAuUHiD47vXbmqj_HzZfd5jK8zB6GhmP-Ew,10984
35
- uiprotect-0.4.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
- uiprotect-0.4.1.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
- uiprotect-0.4.1.dist-info/RECORD,,
33
+ uiprotect-0.5.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
+ uiprotect-0.5.0.dist-info/METADATA,sha256=lofryisrm6u9ASPQ0r77MqHKRqWNUE1XkAzuUrlBBYI,10984
35
+ uiprotect-0.5.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
+ uiprotect-0.5.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
+ uiprotect-0.5.0.dist-info/RECORD,,