mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-12 18:38:03 +00:00
Refactor devices into subpackages and deprecate old names (#716)
* Refactor devices into subpackages and deprecate old names * Tweak and add tests * Fix linting * Remove duplicate implementations affecting project coverage * Update post review * Add device base class attributes and rename subclasses * Rename Module to BaseModule * Remove has_emeter_history * Fix missing _time in init * Update post review * Fix test_readmeexamples * Fix erroneously duped files * Clean up iot and smart imports * Update post latest review * Tweak Device docstring
This commit is contained in:
@@ -6,15 +6,17 @@ This script can be used to create fixture files for individual modules.
|
||||
import asyncio
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import cast
|
||||
|
||||
import typer
|
||||
|
||||
from kasa import Discover, SmartDevice
|
||||
from kasa import Discover
|
||||
from kasa.iot import IotDevice
|
||||
|
||||
app = typer.Typer()
|
||||
|
||||
|
||||
def create_fixtures(dev: SmartDevice, outputdir: Path):
|
||||
def create_fixtures(dev: IotDevice, outputdir: Path):
|
||||
"""Iterate over supported modules and create version-specific fixture files."""
|
||||
for name, module in dev.modules.items():
|
||||
module_dir = outputdir / name
|
||||
@@ -43,13 +45,14 @@ def create_module_fixtures(
|
||||
"""Create module fixtures for given host/network."""
|
||||
devs = []
|
||||
if host is not None:
|
||||
dev: SmartDevice = asyncio.run(Discover.discover_single(host))
|
||||
dev: IotDevice = cast(IotDevice, asyncio.run(Discover.discover_single(host)))
|
||||
devs.append(dev)
|
||||
else:
|
||||
if network is None:
|
||||
network = "255.255.255.255"
|
||||
devs = asyncio.run(Discover.discover(target=network)).values()
|
||||
for dev in devs:
|
||||
dev = cast(IotDevice, dev)
|
||||
asyncio.run(dev.update())
|
||||
|
||||
for dev in devs:
|
||||
|
Reference in New Issue
Block a user