move class InverterIfc into a separate file
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
from abc import abstractmethod
|
|
||||||
import weakref
|
import weakref
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
@@ -8,7 +7,7 @@ from aiomqtt import MqttCodeError
|
|||||||
from asyncio import StreamReader, StreamWriter
|
from asyncio import StreamReader, StreamWriter
|
||||||
|
|
||||||
if __name__ == "app.src.inverter_base":
|
if __name__ == "app.src.inverter_base":
|
||||||
from app.src.iter_registry import AbstractIterMeta
|
from app.src.inverter_ifc import InverterIfc
|
||||||
from app.src.proxy import Proxy
|
from app.src.proxy import Proxy
|
||||||
from app.src.async_stream import StreamPtr
|
from app.src.async_stream import StreamPtr
|
||||||
from app.src.async_stream import AsyncStreamClient
|
from app.src.async_stream import AsyncStreamClient
|
||||||
@@ -16,7 +15,7 @@ if __name__ == "app.src.inverter_base":
|
|||||||
from app.src.config import Config
|
from app.src.config import Config
|
||||||
from app.src.infos import Infos
|
from app.src.infos import Infos
|
||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
from iter_registry import AbstractIterMeta
|
from inverter_ifc import InverterIfc
|
||||||
from proxy import Proxy
|
from proxy import Proxy
|
||||||
from async_stream import StreamPtr
|
from async_stream import StreamPtr
|
||||||
from async_stream import AsyncStreamClient
|
from async_stream import AsyncStreamClient
|
||||||
@@ -27,36 +26,6 @@ else: # pragma: no cover
|
|||||||
logger_mqtt = logging.getLogger('mqtt')
|
logger_mqtt = logging.getLogger('mqtt')
|
||||||
|
|
||||||
|
|
||||||
class InverterIfc(metaclass=AbstractIterMeta):
|
|
||||||
_registry = []
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __init__(self, reader: StreamReader, writer: StreamWriter,
|
|
||||||
config_id: str, prot_class,
|
|
||||||
client_mode: bool):
|
|
||||||
pass # pragma: no cover
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __enter__(self):
|
|
||||||
pass # pragma: no cover
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __exit__(self, exc_type, exc, tb):
|
|
||||||
pass # pragma: no cover
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def healthy(self) -> bool:
|
|
||||||
pass # pragma: no cover
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
async def disc(self, shutdown_started=False) -> None:
|
|
||||||
pass # pragma: no cover
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
async def create_remote(self) -> None:
|
|
||||||
pass # pragma: no cover
|
|
||||||
|
|
||||||
|
|
||||||
class InverterBase(InverterIfc, Proxy):
|
class InverterBase(InverterIfc, Proxy):
|
||||||
|
|
||||||
def __init__(self, reader: StreamReader, writer: StreamWriter,
|
def __init__(self, reader: StreamReader, writer: StreamWriter,
|
||||||
|
|||||||
40
app/src/inverter_ifc.py
Normal file
40
app/src/inverter_ifc.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
from abc import abstractmethod
|
||||||
|
import logging
|
||||||
|
from asyncio import StreamReader, StreamWriter
|
||||||
|
|
||||||
|
if __name__ == "app.src.inverter_ifc":
|
||||||
|
from app.src.iter_registry import AbstractIterMeta
|
||||||
|
else: # pragma: no cover
|
||||||
|
from iter_registry import AbstractIterMeta
|
||||||
|
|
||||||
|
logger_mqtt = logging.getLogger('mqtt')
|
||||||
|
|
||||||
|
|
||||||
|
class InverterIfc(metaclass=AbstractIterMeta):
|
||||||
|
_registry = []
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def __init__(self, reader: StreamReader, writer: StreamWriter,
|
||||||
|
config_id: str, prot_class,
|
||||||
|
client_mode: bool):
|
||||||
|
pass # pragma: no cover
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def __enter__(self):
|
||||||
|
pass # pragma: no cover
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def __exit__(self, exc_type, exc, tb):
|
||||||
|
pass # pragma: no cover
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def healthy(self) -> bool:
|
||||||
|
pass # pragma: no cover
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def disc(self, shutdown_started=False) -> None:
|
||||||
|
pass # pragma: no cover
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def create_remote(self) -> None:
|
||||||
|
pass # pragma: no cover
|
||||||
@@ -6,7 +6,7 @@ from asyncio import StreamReader, StreamWriter
|
|||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from logging import config # noqa F401
|
from logging import config # noqa F401
|
||||||
from proxy import Proxy
|
from proxy import Proxy
|
||||||
from inverter_base import InverterIfc
|
from inverter_ifc import InverterIfc
|
||||||
from gen3.inverter_g3 import InverterG3
|
from gen3.inverter_g3 import InverterG3
|
||||||
from gen3plus.inverter_g3p import InverterG3P
|
from gen3plus.inverter_g3p import InverterG3P
|
||||||
from scheduler import Schedule
|
from scheduler import Schedule
|
||||||
|
|||||||
Reference in New Issue
Block a user