uiprotect 4.2.0__py3-none-any.whl → 5.0.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/__init__.py CHANGED
@@ -7,7 +7,6 @@ from .exceptions import Invalid, NotAuthorized, NvrError
7
7
  from .utils import (
8
8
  get_nested_attr,
9
9
  get_nested_attr_as_bool,
10
- get_top_level_attr,
11
10
  get_top_level_attr_as_bool,
12
11
  make_enabled_getter,
13
12
  make_required_getter,
@@ -21,7 +20,6 @@ __all__ = [
21
20
  "ProtectApiClient",
22
21
  "get_nested_attr",
23
22
  "get_nested_attr_as_bool",
24
- "get_top_level_attr",
25
23
  "get_top_level_attr_as_bool",
26
24
  "make_value_getter",
27
25
  "make_enabled_getter",
@@ -359,7 +359,7 @@ class SampleDataGenerator:
359
359
  length = int((motion_event["end"] - motion_event["start"]) / 1000)
360
360
  if self.anonymize:
361
361
  run(
362
- split( # noqa: S603
362
+ split(
363
363
  BLANK_VIDEO_CMD.format(
364
364
  length=length,
365
365
  filename=self.output_folder / f"{filename}.mp4",
uiprotect/utils.py CHANGED
@@ -634,7 +634,7 @@ def get_nested_attr(attrs: tuple[str, ...], obj: Any) -> Any:
634
634
  for key in attrs:
635
635
  if (value := getattr(value, key, _SENTINEL)) is _SENTINEL:
636
636
  return None
637
- return value.value if isinstance(value, Enum) else value
637
+ return value
638
638
 
639
639
 
640
640
  def get_nested_attr_as_bool(attrs: tuple[str, ...], obj: Any) -> bool:
@@ -643,25 +643,18 @@ def get_nested_attr_as_bool(attrs: tuple[str, ...], obj: Any) -> bool:
643
643
  for key in attrs:
644
644
  if (value := getattr(value, key, _SENTINEL)) is _SENTINEL:
645
645
  return False
646
- return bool(value.value if isinstance(value, Enum) else value)
647
-
648
-
649
- def get_top_level_attr(attr: str, obj: Any) -> Any:
650
- """Fetch a top level attribute."""
651
- value = getattr(obj, attr)
652
- return value.value if isinstance(value, Enum) else value
646
+ return bool(value)
653
647
 
654
648
 
655
649
  def get_top_level_attr_as_bool(attr: str, obj: Any) -> Any:
656
650
  """Fetch a top level attribute as a bool."""
657
- value = getattr(obj, attr)
658
- return bool(value.value if isinstance(value, Enum) else value)
651
+ return bool(getattr(obj, attr))
659
652
 
660
653
 
661
654
  def make_value_getter(ufp_value: str) -> Callable[[T], Any]:
662
655
  """Return a function to get a value from a Protect device."""
663
656
  if "." not in ufp_value:
664
- return partial(get_top_level_attr, ufp_value)
657
+ return attrgetter(ufp_value)
665
658
  return partial(get_nested_attr, tuple(ufp_value.split(".")))
666
659
 
667
660
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 4.2.0
3
+ Version: 5.0.0
4
4
  Summary: Python API for Unifi Protect (Unofficial)
5
5
  Home-page: https://github.com/uilibs/uiprotect
6
6
  Author: UI Protect Maintainers
@@ -1,4 +1,4 @@
1
- uiprotect/__init__.py,sha256=UdpRSSLSy7pdDfTKf0zRIfy6KRGt_Jv-fMzYWgibbG4,686
1
+ uiprotect/__init__.py,sha256=GDRM9WvWUBbOyBVgltq6Qv8i7LVdWEbG8q5EzYvOFbE,636
2
2
  uiprotect/__main__.py,sha256=C_bHCOkv5qj6WMy-6ELoY3Y6HDhLxOa1a30CzmbZhsg,462
3
3
  uiprotect/api.py,sha256=8zfSeqDKArG2pbvImqibQx4HrMi_y06fYXrgcwYztCc,67585
4
4
  uiprotect/cli/__init__.py,sha256=1MO8rJmjjAsfVx2x01gn5DJo8B64xdPGo6gRVJbWd18,8868
@@ -26,12 +26,12 @@ uiprotect/exceptions.py,sha256=kgn0cRM6lTtgLza09SDa3ZiX6ue1QqHCOogQ4qu6KTQ,965
26
26
  uiprotect/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  uiprotect/release_cache.json,sha256=NamnSFy78hOWY0DPO87J9ELFCAN6NnVquv8gQO75ZG4,386
28
28
  uiprotect/stream.py,sha256=McV3XymKyjn-1uV5jdQHcpaDjqLS4zWyMASQ8ubcyb4,4924
29
- uiprotect/test_util/__init__.py,sha256=whiOUb5LfDLNT3AQG6ISiKtAqO2JnhCIdFavhWDK46M,18718
29
+ uiprotect/test_util/__init__.py,sha256=Ky8mTL61nhp5II2mxTKBAsSGvNqK8U_CfKC5AGwToAI,18704
30
30
  uiprotect/test_util/anonymize.py,sha256=f-8ijU-_y9r-uAbhIPn0f0I6hzJpAkvJzc8UpWihObI,8478
31
- uiprotect/utils.py,sha256=G0WkMXpCky2Cc4jynFDFFxAcVaZX4F01OXKa6cx9pho,20121
31
+ uiprotect/utils.py,sha256=9ny9-GMn5Fpnxaw9i769VTIDp4ntfgiCCItqJYWepns,19769
32
32
  uiprotect/websocket.py,sha256=D5DZrMzo434ecp8toNxOB5HM193kVwYw42yEcg99yMw,8029
33
- uiprotect-4.2.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
- uiprotect-4.2.0.dist-info/METADATA,sha256=0Wq8hI7efhmNMHGUJQQvDtN5WeB0tIAdNwbRnYNsIZ0,11009
35
- uiprotect-4.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
- uiprotect-4.2.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
- uiprotect-4.2.0.dist-info/RECORD,,
33
+ uiprotect-5.0.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
+ uiprotect-5.0.0.dist-info/METADATA,sha256=wE8gx41SJjaYT-w5RA_6a-qZoauXYIxEqFKG1X1Se_4,11009
35
+ uiprotect-5.0.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
+ uiprotect-5.0.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
+ uiprotect-5.0.0.dist-info/RECORD,,