Structure cli into a package (#1038)

PR with just the initial structural changes for the cli to be a package.
Subsequent PR will break out `main.py` into modules. Doing it in two
stages ensure that the commit history will be continuous for `cli.py` >
`cli/main.py`
This commit is contained in:
Steven B 2024-07-04 13:52:01 +01:00 committed by GitHub
parent 7427a88570
commit 983aacbc24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 11 additions and 5 deletions

View File

@ -8,7 +8,7 @@ import click
import dpkt import dpkt
from dpkt.ethernet import ETH_TYPE_IP, Ethernet from dpkt.ethernet import ETH_TYPE_IP, Ethernet
from kasa.cli import echo from kasa.cli.main import echo
from kasa.xortransport import XorEncryption from kasa.xortransport import XorEncryption

1
kasa/cli/__init__.py Normal file
View File

@ -0,0 +1 @@
"""Package for the cli."""

5
kasa/cli/__main__.py Normal file
View File

@ -0,0 +1,5 @@
"""Main module."""
from kasa.cli.main import cli
cli()

View File

@ -17,7 +17,7 @@ from kasa import (
Module, Module,
UnsupportedDeviceError, UnsupportedDeviceError,
) )
from kasa.cli import ( from kasa.cli.main import (
TYPE_TO_CLASS, TYPE_TO_CLASS,
alias, alias,
brightness, brightness,
@ -500,7 +500,7 @@ async def test_credentials(discovery_mock, mocker, runner):
f"Username:{dev.credentials.username} Password:{dev.credentials.password}" f"Username:{dev.credentials.username} Password:{dev.credentials.password}"
) )
mocker.patch("kasa.cli.state", new=_state) mocker.patch("kasa.cli.main.state", new=_state)
dr = DiscoveryResult(**discovery_mock.discovery_data["result"]) dr = DiscoveryResult(**discovery_mock.discovery_data["result"])
res = await runner.invoke( res = await runner.invoke(
@ -746,7 +746,7 @@ async def test_type_param(device_type, mocker, runner):
nonlocal result_device nonlocal result_device
result_device = dev result_device = dev
mocker.patch("kasa.cli.state", new=_state) mocker.patch("kasa.cli.main.state", new=_state)
expected_type = TYPE_TO_CLASS[device_type] expected_type = TYPE_TO_CLASS[device_type]
mocker.patch.object(expected_type, "update") mocker.patch.object(expected_type, "update")
res = await runner.invoke( res = await runner.invoke(

View File

@ -18,7 +18,7 @@ include = [
"Documentation" = "https://python-kasa.readthedocs.io" "Documentation" = "https://python-kasa.readthedocs.io"
[tool.poetry.scripts] [tool.poetry.scripts]
kasa = "kasa.cli:cli" kasa = "kasa.cli:__main__"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.9" python = "^3.9"