8000 Rename smartcamera to smartcam (#1300) · python-kasa/python-kasa@24dee75 · GitHub
[go: up one dir, main page]

Skip to content

Commit 24dee75

Browse files
sdb9696rytilahti
authored andcommitted
Rename smartcamera to smartcam (#1300)
1 parent e43e745 commit 24dee75

34 files changed

+130
-130
lines changed

devtools/dump_devinfo.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import asyncclick as click
2727

28-
from devtools.helpers.smartcamerarequests import SMARTCAMERA_REQUESTS
28+
from devtools.helpers.smartcamrequests import SMARTCAM_REQUESTS
2929
from devtools.helpers.smartrequests import SmartRequest, get_component_requests
3030
from kasa import (
3131
AuthenticationError,
@@ -42,19 +42,19 @@
4242
from kasa.discover import DiscoveryResult
4343
from kasa.exceptions import SmartErrorCode
4444
from kasa.protocols import IotProtocol
45-
from kasa.protocols.smartcameraprotocol import (
46-
SmartCameraProtocol,
45+
from kasa.protocols.smartcamprotocol import (
46+
SmartCamProtocol,
4747
_ChildCameraProtocolWrapper,
4848
)
4949
from kasa.protocols.smartprotocol import SmartProtocol, _ChildProtocolWrapper
5050
from kasa.smart import SmartChildDevice, SmartDevice
51-
from kasa.smartcamera import SmartCamera
51+
from kasa.smartcam import SmartCamDevice
5252

5353
Call = namedtuple("Call", "module method")
5454
FixtureResult = namedtuple("FixtureResult", "filename, folder, data")
5555

5656
SMART_FOLDER = "tests/fixtures/smart/"
57-
SMARTCAMERA_FOLDER = "tests/fixtures/smartcamera/"
57+
SMARTCAM_FOLDER = "tests/fixtures/smartcam/"
5858
SMART_CHILD_FOLDER = "tests/fixtures/smart/child/"
5959
IOT_FOLDER = "tests/fixtures/iot/"
6060

@@ -65,7 +65,7 @@
6565

6666
@dataclasses.dataclass
6767
class SmartCall:
68-
"""Class for smart and smartcamera calls."""
68+
"""Class for smart and smartcam calls."""
6969

7070
module: str
7171
request: dict
@@ -562,7 +562,7 @@ async def _make_requests_or_exit(
562562
# Calling close on child protocol wrappers is a noop
563563
protocol_to_close = protocol
564564
if child_device_id:
565-
if isinstance(protocol, SmartCameraProtocol):
565+
if isinstance(protocol, SmartCamProtocol):
566566
protocol = _ChildCameraProtocolWrapper(child_device_id, protocol)
567567
else:
568568
protocol = _ChildProtocolWrapper(child_device_id, protocol)
@@ -608,7 +608,7 @@ async def get_smart_camera_test_calls(protocol: SmartProtocol):
608608
successes: list[SmartCall] = []
609609

610610
test_calls = []
611-
for request in SMARTCAMERA_REQUESTS:
611+
for request in SMARTCAM_REQUESTS:
612612
method = next(iter(request))
613613
if method == "get":
614614
module = method + "_" + next(iter(request[method]))
@@ -693,7 +693,7 @@ async def get_smart_camera_test_calls(protocol: SmartProtocol):
693693
click.echo(f"Skipping {component_id}..", nl=False)
694694
click.echo(click.style("UNSUPPORTED", fg="yellow"))
695695
else: # Not a smart protocol device so assume camera protocol
696-
for request in SMARTCAMERA_REQUESTS:
696+
for request in SMARTCAM_REQUESTS:
697697
method = next(iter(request))
698698
if method == "get":
699699
method = method + "_" + next(iter(request[method]))
@@ -858,7 +858,7 @@ async def get_smart_fixtures(
858858
protocol: SmartProtocol, *, discovery_info: dict[str, Any] | None, batch_size: int
859859
) -> list[FixtureResult]:
860860
"""Get fixture for new TAPO style protocol."""
861-
if isinstance(protocol, SmartCameraProtocol):
861+
if isinstance(protocol, SmartCamProtocol):
862862
test_calls, successes = await get_smart_camera_test_calls(protocol)
863863
child_wrapper: type[_ChildProtocolWrapper | _ChildCameraProtocolWrapper] = (
864864
_ChildCameraProtocolWrapper
@@ -991,8 +991,8 @@ async def get_smart_fixtures(
991991
copy_folder = SMART_FOLDER
992992
else:
993993
# smart camera protocol
994-
model_info = SmartCamera._get_device_info(final, discovery_info)
995-
copy_folder = SMARTCAMERA_FOLDER
994+
model_info = SmartCamDevice._get_device_info(final, discovery_info)
995+
copy_folder = SMARTCAM_FOLDER
996996
hw_version = model_info.hardware_version
997997
sw_version = model_info.firmware_version
998998
model = model_info.long_name

devtools/generate_supported.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from kasa.device_type import DeviceType
1414
from kasa.iot import IotDevice
1515
from kasa.smart import SmartDevice
16-
from kasa.smartcamera import SmartCamera
16+
from kasa.smartcam import SmartCamDevice
1717< 558 div class="diff-text-inner">
1818

1919
class SupportedVersion(NamedTuple):
@@ -48,7 +48,7 @@ class SupportedVersion(NamedTuple):
4848
IOT_FOLDER = "tests/fixtures/iot/"
4949
SMART_FOLDER = "tests/fixtures/smart/"
5050
SMART_CHILD_FOLDER = "tests/fixtures/smart/child"
51-
SMARTCAMERA_FOLDER = "tests/fixtures/smartcamera/"
51+
SMARTCAM_FOLDER = "tests/fixtures/smartcam/"
5252

5353

5454
def generate_supported(args):
@@ -65,7 +65,7 @@ def generate_supported(args):
6565
_get_supported_devices(supported, IOT_FOLDER, IotDevice)
6666
_get_supported_devices(supported, SMART_FOLDER, SmartDevice)
6767
_get_supported_devices(supported, SMART_CHILD_FOLDER, SmartDevice)
68-
_get_supported_devices(supported, SMARTCAMERA_FOLDER, SmartCamera)
68+
_get_supported_devices(supported, SMARTCAM_FOLDER, SmartCamDevice)
6969

7070
readme_updated = _update_supported_file(
7171
README_FILENAME, _supported_summary(supported), print_diffs
@@ -208,7 +208,7 @@ def _supported_text(
208208
def _get_supported_devices(
209209
supported: dict[str, Any],
210210
fixture_location: str,
211-
device_cls: type[IotDevice | SmartDevice | SmartCamera],
211+
device_cls: type[IotDevice | SmartDevice | SmartCamDevice],
212212
):
213213
for file in Path(fixture_location).glob("*.json"):
214214
with file.open() as f:

devtools/helpers/smartcamerarequests.py renamed to devtools/helpers/smartcamrequests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
SMARTCAMERA_REQUESTS: list[dict] = [
5+
SMARTCAM_REQUESTS: list[dict] = [
66
{"getAlertTypeList": {"msg_alarm": {"name": "alert_type"}}},
77
{"getNightVisionCapability": {"image_capability": {"name": ["supplement_lamp"]}}},
88
{"getDeviceInfo": {"device_info": {"name": ["basic_info"]}}},

kasa/device_factory.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
IotProtocol,
2525
SmartProtocol,
2626
)
27-
from .protocols.smartcameraprotocol import SmartCameraProtocol
27+
from .protocols.smartcamprotocol import SmartCamProtocol
2828
from .smart import SmartDevice
29-
from .smartcamera.smartcamera import SmartCamera
29+
from .smartcam import SmartCamDevice
3030
from .transports import (
3131
AesTransport,
3232
BaseTransport,
@@ -151,10 +151,10 @@ def get_device_class_from_family(
151151
"SMART.TAPOSWITCH": SmartDevice,
152152
"SMART.KASAPLUG": SmartDevice,
153153
"SMART.TAPOHUB": SmartDevice,
154-
"SMART.TAPOHUB.HTTPS": SmartCamera,
154+
"SMART.TAPOHUB.HTTPS": SmartCamDevice,
155155
"SMART.KASAHUB": SmartDevice,
156156
"SMART.KASASWITCH": SmartDevice,
157-
"SMART.IPCAMERA.HTTPS": SmartCamera,
157+
"SMART.IPCAMERA.HTTPS": SmartCamDevice,
158158
"IOT.SMARTPLUGSWITCH": IotPlug,
159159
"IOT.SMARTBULB": IotBulb,
160160
}
@@ -189,7 +189,7 @@ def get_protocol(
189189
"IOT.KLAP": (IotProtocol, KlapTransport),
190190
"SMART.AES": (SmartProtocol, AesTransport),
191191
"SMART.KLAP": (SmartProtocol, KlapTransportV2),
192-
"SMART.AES.HTTPS": (SmartCameraProtocol, SslAesTransport),
192+
"SMART.AES.HTTPS": (SmartCamProtocol, SslAesTransport),
193193
}
194194
if not (prot_tran_cls := supported_device_protocols.get(protocol_transport_key)):
195195
return None

kasa/module.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
from .device import Device
6161
from .iot import modules as iot
6262
from .smart import modules as smart
63-
from .smartcamera import modules as smartcamera
63+
from .smartcam import modules as smartcam
6464

6565
_LOGGER = logging.getLogger(__name__)
6666

@@ -139,8 +139,8 @@ class Module(ABC):
139139
)
140140
TriggerLogs: Final[ModuleName[smart.TriggerLogs]] = ModuleName("TriggerLogs")
141141

142-
# SMARTCAMERA only modules
143-
Camera: Final[ModuleName[smartcamera.Camera]] = ModuleName("Camera")
142+
# SMARTCAM only modules
143+
Camera: Final[ModuleName[smartcam.Camera]] = ModuleName("Camera")
144144

145145
def __init__(self, device: Device, module: str) -> None:
146146
self._device = device

kasa/protocols/smartcameraprotocol.py renamed to kasa/protocols/smartcamprotocol.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Module for SmartCamera Protocol."""
1+
"""Module for SmartCamProtocol."""
22

33
from __future__ import annotations
44

@@ -46,8 +46,8 @@ class SingleRequest:
4646
request: dict[str, Any]
4747

4848

49-
class SmartCameraProtocol(SmartProtocol):
50-
"""Class for SmartCamera Protocol."""
49+
class SmartCamProtocol(SmartProtocol):
50+
"""Class for SmartCam Protocol."""
5151

5252
async def _handle_response_lists(
5353
self, response_result: dict[str, Any], method: str, retry_count: int
@@ -123,7 +123,7 @@ def _make_smart_camera_single_request(
123123
"""
124124
method = request
125125
method_type = request[:3]
126-
snake_name = SmartCameraProtocol._make_snake_name(request)
126+
snake_name = SmartCamProtocol._make_snake_name(request)
127127
param = snake_name[4:]
128128
if (
129129
(short_method := method[:3])

kasa/protocols/smartprotocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ async def _execute_multiple_query(self, requests: dict, retry_count: int) -> dic
168168
]
169169

170170
end = len(multi_requests)
171-
# The SmartCameraProtocol sends requests with a length 1 as a
171+
# The SmartCamProtocol sends requests with a length 1 as a
172172
# multipleRequest. The SmartProtocol doesn't so will never
173173
# raise_on_error
174174
raise_on_error = end == 1

kasa/smartcam/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Package for supporting tapo-branded cameras."""
2+
3+
from .smartcamdevice import SmartCamDevice
4+
5+
__all__ = ["SmartCamDevice"]

kasa/smartcamera/modules/__init__.py renamed to kasa/smartcam/modules/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Modules for SMARTCAMERA devices."""
1+
"""Modules for SMARTCAM devices."""
22

33
from .alarm import Alarm
44
from .camera import Camera

kasa/smartcamera/modules/alarm.py renamed to kasa/smartcam/modules/alarm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from ...feature import Feature
6-
from ..smartcameramodule import SmartCameraModule
6+
from ..smartcammodule import SmartCamModule
77

88
DURATION_MIN = 0
99
DURATION_MAX = 6000
@@ -12,11 +12,11 @@
1212
VOLUME_MAX = 10
1313

1414

15-
class Alarm(SmartCameraModule):
15+
class Alarm(SmartCamModule):
1616
"""Implementation of alarm module."""
1717

1818
# Needs a different name to avoid clashing with SmartAlarm
19-
NAME = "SmartCameraAlarm"
19+
NAME = "SmartCamAlarm"
2020

2121
REQUIRED_COMPONENT = "siren"
2222
QUERY_GETTER_NAME = "getSirenStatus"

kasa/smartcamera/modules/camera.py renamed to kasa/smartcam/modules/camera.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
from ...device_type import DeviceType
1111
from ...feature import Feature
1212
from ...json import loads as json_loads
13-
from ..smartcameramodule import SmartCameraModule
13+
from ..smartcammodule import SmartCamModule
1414

1515
_LOGGER = logging.getLogger(__name__)
1616

1717
LOCAL_STREAMING_PORT = 554
1818

1919

20-
class Camera(SmartCameraModule):
20+
class Camera(SmartCamModule):
2121
"""Implementation of device module."""
2222

2323
QUERY_GETTER_NAME = "getLensMaskConfig"

kasa/smartcamera/modules/childdevice.py renamed to kasa/smartcam/modules/childdevice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Module for child devices."""
22

33
from ...device_type import DeviceType
4-
from ..smartcameramodule import SmartCameraModule
4+
from ..smartcammodule import SmartCamModule
55

66

7-
class ChildDevice(SmartCameraModule):
7+
class ChildDevice(SmartCamModule):
88
"""Implementation for child devices."""
99

1010
REQUIRED_COMPONENT = "childControl"

kasa/smartcamera/modules/device.py renamed to kasa/smartcam/modules/device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from __future__ import annotations
44

55
from ...feature import Feature
6-
from ..smartcameramodule import SmartCameraModule
6+
from ..smartcammodule import SmartCamModule
77

88

9-
class DeviceModule(SmartCameraModule):
9+
class DeviceModule(SmartCamModule):
1010
"""Implementation of device module."""
1111

1212
NAME = "devicemodule"

kasa/smartcamera/modules/led.py renamed to kasa/smartcam/modules/led.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from __future__ import annotations
44

55
from ...interfaces.led import Led as LedInterface
6-
from ..smartcameramodule import SmartCameraModule
6+
from ..smartcammodule import SmartCamModule
77

88

9-
class Led(SmartCameraModule, LedInterface):
9+
class Led(SmartCamModule, LedInterface):
1010
"""Implementation of led controls."""
1111

1212
REQUIRED_COMPONENT = "led"

kasa/smartcamera/modules/pantilt.py renamed to kasa/smartcam/modules/pantilt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from __future__ import annotations
44

55
from ...feature import Feature
6-
from ..smartcameramodule import SmartCameraModule
6+
from ..smartcammodule import SmartCamModule
77

88
DEFAULT_PAN_STEP = 30
99
DEFAULT_TILT_STEP = 10
1010

1111

12-
class PanTilt(SmartCameraModule):
12+
class PanTilt(SmartCamModule):
1313
"""Implementation of device_local_time."""
1414

1515
REQUIRED_COMPONENT = "ptz"

kasa/smartcamera/modules/time.py renamed to kasa/smartcam/modules/time.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from ...cachedzoneinfo import CachedZoneInfo
1010
from ...feature import Feature
1111
from ...interfaces import Time as TimeInterface
12-
from ..smartcameramodule import SmartCameraModule
12+
from ..smartcammodule import SmartCamModule
1313

1414

15-
class Time(SmartCameraModule, TimeInterface):
15+
class Time(SmartCamModule, TimeInterface):
1616
"""Implementation of device_local_time."""
1717

1818
QUERY_GETTER_NAME = "getTimezone"

kasa/smartcamera/smartcamera.py renamed to kasa/smartcam/smartcamdevice.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Module for smartcamera."""
1+
"""Module for SmartCamDevice."""
22

33
from __future__ import annotations
44

@@ -8,15 +8,15 @@
88
from ..device import _DeviceInfo
99
from ..device_type import DeviceType
1010
from ..module import Module
11-
from ..protocols.smartcameraprotocol import _ChildCameraProtocolWrapper
11+
from ..protocols.smartcamprotocol import _ChildCameraProtocolWrapper
1212
from ..smart import SmartChildDevice, SmartDevice
1313
from .modules import ChildDevice, DeviceModule
14-
from .smartcameramodule import SmartCameraModule
14+
from .smartcammodule import SmartCamModule
1515

1616
_LOGGER = logging.getLogger(__name__)
1717

1818

19-
class SmartCamera(SmartDevice):
19+
class SmartCamDevice(SmartDevice):
2020
"""Class for smart cameras."""
2121

2222
# Modules that are called as part of the init procedure on first update
@@ -41,7 +41,7 @@ def _get_device_info(
4141
basic_info = info["getDeviceInfo"]["device_info"]["basic_info"]
4242
short_name = basic_info["device_model"]
4343
long_name = discovery_info["device_model"] if discovery_info else short_name
44-
device_type = SmartCamera._get_device_type_from_sysinfo(basic_info)
44+
device_type = SmartCamDevice._get_device_type_from_sysinfo(basic_info)
4545
fw_version_full = basic_info["sw_version"]
4646
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
4747
return _DeviceInfo(
@@ -73,7 +73,7 @@ def _update_children_info(self) -> None:
7373
async def _initialize_smart_child(
7474
self, info: dict, child_components: dict
7575
) -> SmartDevice:
76-
"""Initialize a smart child device attached to a smartcamera."""
76+
"""Initialize a smart child device attached to a smartcam device."""
7777
child_id = info["device_id"]
7878
child_protocol = _ChildCameraProtocolWrapper(child_id, self.protocol)
7979
try:
@@ -122,7 +122,7 @@ async def _initialize_children(self) -> None:
122122

123123
async def _initialize_modules(self) -> None:
124124
"""Initialize modules based on component negotiation response."""
125-
for mod in SmartCameraModule.REGISTERED_MODULES.values():
125+
for mod in SmartCamModule.REGISTERED_MODULES.values():
126126
if (
127127
mod.REQUIRED_COMPONENT
128128
and mod.REQUIRED_COMPONENT not in self._components

0 commit comments

Comments
 (0)
0