mirror of
				https://github.com/python-kasa/python-kasa.git
				synced 2025-10-30 20:21:54 +00:00 
			
		
		
		
	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:
		| @@ -8,7 +8,7 @@ import click | ||||
| import dpkt | ||||
| from dpkt.ethernet import ETH_TYPE_IP, Ethernet | ||||
|  | ||||
| from kasa.cli import echo | ||||
| from kasa.cli.main import echo | ||||
| from kasa.xortransport import XorEncryption | ||||
|  | ||||
|  | ||||
|   | ||||
							
								
								
									
										1
									
								
								kasa/cli/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								kasa/cli/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| """Package for the cli.""" | ||||
							
								
								
									
										5
									
								
								kasa/cli/__main__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								kasa/cli/__main__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| """Main module.""" | ||||
|  | ||||
| from kasa.cli.main import cli | ||||
|  | ||||
| cli() | ||||
| @@ -17,7 +17,7 @@ from kasa import ( | ||||
|     Module, | ||||
|     UnsupportedDeviceError, | ||||
| ) | ||||
| from kasa.cli import ( | ||||
| from kasa.cli.main import ( | ||||
|     TYPE_TO_CLASS, | ||||
|     alias, | ||||
|     brightness, | ||||
| @@ -500,7 +500,7 @@ async def test_credentials(discovery_mock, mocker, runner): | ||||
|                 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"]) | ||||
|     res = await runner.invoke( | ||||
| @@ -746,7 +746,7 @@ async def test_type_param(device_type, mocker, runner): | ||||
|         nonlocal result_device | ||||
|         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] | ||||
|     mocker.patch.object(expected_type, "update") | ||||
|     res = await runner.invoke( | ||||
|   | ||||
| @@ -18,7 +18,7 @@ include = [ | ||||
| "Documentation" = "https://python-kasa.readthedocs.io" | ||||
|  | ||||
| [tool.poetry.scripts] | ||||
| kasa = "kasa.cli:cli" | ||||
| kasa = "kasa.cli:__main__" | ||||
|  | ||||
| [tool.poetry.dependencies] | ||||
| python = "^3.9" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Steven B
					Steven B