remove builder progress logs, they aren't very useful and we test the factories anyway.

This commit is contained in:
2026-03-20 03:28:20 +00:00
parent 6eaa799c20
commit 821371ee27

View File

@@ -1,5 +1,4 @@
import logging
from enum import IntEnum
from functools import cached_property
from typing import Iterable
@@ -9,7 +8,7 @@ from .command import Command
from .config import request_config as configs
from .device import Device
from .error import VMError
from .kinds import KindMapClass
from .kinds import KindId, KindMapClass
from .kinds import request_kind_map as kindmap
from .macrobutton import MacroButton
from .recorder import Recorder
@@ -27,34 +26,11 @@ class FactoryBuilder:
Separates construction from representation.
"""
BuilderProgress = IntEnum(
'BuilderProgress',
'strip bus command macrobutton vban device option recorder patch fx',
start=0,
)
def __init__(self, factory, kind: KindMapClass):
self._factory = factory
self.kind = kind
self._info = (
f'Finished building strips for {self._factory}',
f'Finished building buses for {self._factory}',
f'Finished building commands for {self._factory}',
f'Finished building macrobuttons for {self._factory}',
f'Finished building vban in/out streams for {self._factory}',
f'Finished building device for {self._factory}',
f'Finished building option for {self._factory}',
f'Finished building recorder for {self._factory}',
f'Finished building patch for {self._factory}',
f'Finished building fx for {self._factory}',
)
self.logger = logger.getChild(self.__class__.__name__)
def _pinfo(self, name: str) -> None:
"""prints progress status for each step"""
name = name.split('_')[1]
self.logger.debug(self._info[int(getattr(self.BuilderProgress, name))])
def make_strip(self):
self._factory.strip = tuple(
strip(i < self.kind.phys_in, self._factory, i)
@@ -151,12 +127,14 @@ class BasicFactory(FactoryBase):
def __new__(cls, *args, **kwargs):
if cls is BasicFactory:
raise TypeError(f"'{cls.__name__}' does not support direct instantiation")
ERR_MSG = f"'{cls.__name__}' does not support direct instantiation"
raise TypeError(ERR_MSG)
return object.__new__(cls)
def __init__(self, kind_id, **kwargs):
super().__init__(kind_id, **kwargs)
[step()._pinfo(step.__name__) for step in self.steps]
for step in self.steps:
step()
@property
def steps(self) -> Iterable:
@@ -173,12 +151,14 @@ class BananaFactory(FactoryBase):
def __new__(cls, *args, **kwargs):
if cls is BananaFactory:
raise TypeError(f"'{cls.__name__}' does not support direct instantiation")
ERR_MSG = f"'{cls.__name__}' does not support direct instantiation"
raise TypeError(ERR_MSG)
return object.__new__(cls)
def __init__(self, kind_id, **kwargs):
super().__init__(kind_id, **kwargs)
[step()._pinfo(step.__name__) for step in self.steps]
for step in self.steps:
step()
@property
def steps(self) -> Iterable:
@@ -195,12 +175,14 @@ class PotatoFactory(FactoryBase):
def __new__(cls, *args, **kwargs):
if cls is PotatoFactory:
raise TypeError(f"'{cls.__name__}' does not support direct instantiation")
ERR_MSG = f"'{cls.__name__}' does not support direct instantiation"
raise TypeError(ERR_MSG)
return object.__new__(cls)
def __init__(self, kind_id: str, **kwargs):
super().__init__(kind_id, **kwargs)
[step()._pinfo(step.__name__) for step in self.steps]
for step in self.steps:
step()
@property
def steps(self) -> Iterable:
@@ -226,7 +208,8 @@ def remote_factory(kind_id: str, **kwargs) -> Remote:
case 'potato':
_factory = PotatoFactory
case _:
raise ValueError(f"Unknown Voicemeeter kind '{kind_id}'")
ERR_MSG = f'Unknown Voicemeeter kind {kind_id}, expected one of {[k.name.lower() for k in KindId]}'
raise ValueError(ERR_MSG)
return type(f'Remote{kind_id.capitalize()}', (_factory,), {})(kind_id, **kwargs)
@@ -243,6 +226,6 @@ def request_remote_obj(kind_id: str, **kwargs) -> Remote:
try:
REMOTE_obj = remote_factory(kind_id, **kwargs)
except (ValueError, TypeError) as e:
logger_entry.exception(f'{type(e).__name__}: {e}')
logger_entry.error(f'{type(e).__name__}: {e}')
raise VMError(str(e)) from e
return REMOTE_obj