mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-05-12 14:33:31 +00:00
Compare commits
11 Commits
v2.10.3
...
84990367bd
| Author | SHA1 | Date | |
|---|---|---|---|
| 84990367bd | |||
| 5aae5dcba6 | |||
| a34beca205 | |||
|
|
c364db503b | ||
| 6e00ee014c | |||
| d7b73e773a | |||
| ba85373f94 | |||
| 22cc980fc2 | |||
|
|
2986d451ad | ||
| 96f0008654 | |||
|
|
6ddead68d0 |
13
.pre-commit-config.yaml
Normal file
13
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v2.3.0
|
||||||
|
hooks:
|
||||||
|
- id: check-yaml
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
|
||||||
|
- repo: https://github.com/python-poetry/poetry
|
||||||
|
rev: '2.3.2'
|
||||||
|
hooks:
|
||||||
|
- id: poetry-check
|
||||||
|
- id: poetry-lock
|
||||||
78
poetry.lock
generated
78
poetry.lock
generated
@@ -1,4 +1,4 @@
|
|||||||
# This file is automatically @generated by Poetry 2.0.1 and should not be changed by hand.
|
# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand.
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cachetools"
|
name = "cachetools"
|
||||||
@@ -55,7 +55,7 @@ description = "Backport of PEP 654 (exception groups)"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
markers = "python_version < \"3.11\""
|
markers = "python_version == \"3.10\""
|
||||||
files = [
|
files = [
|
||||||
{file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"},
|
{file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"},
|
||||||
{file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"},
|
{file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"},
|
||||||
@@ -66,21 +66,16 @@ test = ["pytest (>=6)"]
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filelock"
|
name = "filelock"
|
||||||
version = "3.16.1"
|
version = "3.20.3"
|
||||||
description = "A platform independent file lock."
|
description = "A platform independent file lock."
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.10"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
files = [
|
files = [
|
||||||
{file = "filelock-3.16.1-py3-none-any.whl", hash = "sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0"},
|
{file = "filelock-3.20.3-py3-none-any.whl", hash = "sha256:4b0dda527ee31078689fc205ec4f1c1bf7d56cf88b6dc9426c4f230e46c2dce1"},
|
||||||
{file = "filelock-3.16.1.tar.gz", hash = "sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435"},
|
{file = "filelock-3.20.3.tar.gz", hash = "sha256:18c57ee915c7ec61cff0ecf7f0f869936c7c30191bb0cf406f1341778d0834e1"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.extras]
|
|
||||||
docs = ["furo (>=2024.8.6)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.4.1)"]
|
|
||||||
testing = ["covdefaults (>=2.3)", "coverage (>=7.6.1)", "diff-cover (>=9.2)", "pytest (>=8.3.3)", "pytest-asyncio (>=0.24)", "pytest-cov (>=5)", "pytest-mock (>=3.14)", "pytest-timeout (>=2.3.1)", "virtualenv (>=20.26.4)"]
|
|
||||||
typing = ["typing-extensions (>=4.12.2)"]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iniconfig"
|
name = "iniconfig"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
@@ -150,6 +145,21 @@ files = [
|
|||||||
{file = "pyenv_inspect-0.4.0-py3-none-any.whl", hash = "sha256:618683ae7d3e6db14778d58aa0fc6b3170180d944669b5d35a8aa4fb7db550d2"},
|
{file = "pyenv_inspect-0.4.0-py3-none-any.whl", hash = "sha256:618683ae7d3e6db14778d58aa0fc6b3170180d944669b5d35a8aa4fb7db550d2"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pygments"
|
||||||
|
version = "2.20.0"
|
||||||
|
description = "Pygments is a syntax highlighting package written in Python."
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.9"
|
||||||
|
groups = ["dev"]
|
||||||
|
files = [
|
||||||
|
{file = "pygments-2.20.0-py3-none-any.whl", hash = "sha256:81a9e26dd42fd28a23a2d169d86d7ac03b46e2f8b59ed4698fb4785f946d0176"},
|
||||||
|
{file = "pygments-2.20.0.tar.gz", hash = "sha256:6757cd03768053ff99f3039c1a36d6c0aa0b263438fcab17520b30a303a82b5f"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
windows-terminal = ["colorama (>=0.4.6)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyproject-api"
|
name = "pyproject-api"
|
||||||
version = "1.8.0"
|
version = "1.8.0"
|
||||||
@@ -172,26 +182,27 @@ testing = ["covdefaults (>=2.3)", "pytest (>=8.3.3)", "pytest-cov (>=5)", "pytes
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest"
|
name = "pytest"
|
||||||
version = "8.3.4"
|
version = "9.0.3"
|
||||||
description = "pytest: simple powerful testing with Python"
|
description = "pytest: simple powerful testing with Python"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.10"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
files = [
|
files = [
|
||||||
{file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"},
|
{file = "pytest-9.0.3-py3-none-any.whl", hash = "sha256:2c5efc453d45394fdd706ade797c0a81091eccd1d6e4bccfcd476e2b8e0ab5d9"},
|
||||||
{file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"},
|
{file = "pytest-9.0.3.tar.gz", hash = "sha256:b86ada508af81d19edeb213c681b1d48246c1a91d304c6c81a427674c17eb91c"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
colorama = {version = ">=0.4", markers = "sys_platform == \"win32\""}
|
||||||
exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""}
|
exceptiongroup = {version = ">=1", markers = "python_version < \"3.11\""}
|
||||||
iniconfig = "*"
|
iniconfig = ">=1.0.1"
|
||||||
packaging = "*"
|
packaging = ">=22"
|
||||||
pluggy = ">=1.5,<2"
|
pluggy = ">=1.5,<2"
|
||||||
|
pygments = ">=2.7.2"
|
||||||
tomli = {version = ">=1", markers = "python_version < \"3.11\""}
|
tomli = {version = ">=1", markers = "python_version < \"3.11\""}
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
|
dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "requests", "setuptools", "xmlschema"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest-randomly"
|
name = "pytest-randomly"
|
||||||
@@ -243,7 +254,7 @@ description = "A lil' TOML parser"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
groups = ["main", "dev"]
|
groups = ["main", "dev"]
|
||||||
markers = "python_version < \"3.11\""
|
markers = "python_version == \"3.10\""
|
||||||
files = [
|
files = [
|
||||||
{file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"},
|
{file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"},
|
||||||
{file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"},
|
{file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"},
|
||||||
@@ -309,37 +320,38 @@ test = ["devpi-process (>=1.0.2)", "pytest (>=8.3.3)", "pytest-mock (>=3.14)"]
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typing-extensions"
|
name = "typing-extensions"
|
||||||
version = "4.12.2"
|
version = "4.15.0"
|
||||||
description = "Backported and Experimental Type Hints for Python 3.8+"
|
description = "Backported and Experimental Type Hints for Python 3.9+"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.9"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
markers = "python_version < \"3.11\""
|
markers = "python_version == \"3.10\""
|
||||||
files = [
|
files = [
|
||||||
{file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"},
|
{file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"},
|
||||||
{file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"},
|
{file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "virtualenv"
|
name = "virtualenv"
|
||||||
version = "20.29.0"
|
version = "20.36.1"
|
||||||
description = "Virtual Python Environment builder"
|
description = "Virtual Python Environment builder"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
files = [
|
files = [
|
||||||
{file = "virtualenv-20.29.0-py3-none-any.whl", hash = "sha256:c12311863497992dc4b8644f8ea82d3b35bb7ef8ee82e6630d76d0197c39baf9"},
|
{file = "virtualenv-20.36.1-py3-none-any.whl", hash = "sha256:575a8d6b124ef88f6f51d56d656132389f961062a9177016a50e4f507bbcc19f"},
|
||||||
{file = "virtualenv-20.29.0.tar.gz", hash = "sha256:6345e1ff19d4b1296954cee076baaf58ff2a12a84a338c62b02eda39f20aa982"},
|
{file = "virtualenv-20.36.1.tar.gz", hash = "sha256:8befb5c81842c641f8ee658481e42641c68b5eab3521d8e092d18320902466ba"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
distlib = ">=0.3.7,<1"
|
distlib = ">=0.3.7,<1"
|
||||||
filelock = ">=3.12.2,<4"
|
filelock = {version = ">=3.20.1,<4", markers = "python_version >= \"3.10\""}
|
||||||
platformdirs = ">=3.9.1,<5"
|
platformdirs = ">=3.9.1,<5"
|
||||||
|
typing-extensions = {version = ">=4.13.2", markers = "python_version < \"3.11\""}
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"]
|
docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"]
|
||||||
test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"]
|
test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8) ; platform_python_implementation == \"PyPy\" or platform_python_implementation == \"GraalVM\" or platform_python_implementation == \"CPython\" and sys_platform == \"win32\" and python_version >= \"3.13\"", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10) ; platform_python_implementation == \"CPython\""]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "virtualenv-pyenv"
|
name = "virtualenv-pyenv"
|
||||||
@@ -360,4 +372,4 @@ virtualenv = "*"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.1"
|
lock-version = "2.1"
|
||||||
python-versions = ">=3.10"
|
python-versions = ">=3.10"
|
||||||
content-hash = "13fc9d0eb15d5fc09b54c1c8cd8f528b260259e97ee6813b50ab4724c35d6677"
|
content-hash = "7aa2f3723fd492542331618b2f2b891d8cff630f6984e19fd4c715d269533a46"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "vban-cmd"
|
name = "vban-cmd"
|
||||||
version = "2.10.3"
|
version = "2.10.4"
|
||||||
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
||||||
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
|
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
|
||||||
license = { text = "MIT" }
|
license = { text = "MIT" }
|
||||||
@@ -12,7 +12,7 @@ dependencies = ["tomli (>=2.0.1,<3.0) ; python_version < '3.11'"]
|
|||||||
poethepoet = ">=0.42.0"
|
poethepoet = ">=0.42.0"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
pytest = "^8.3.4"
|
pytest = "^9.0.3"
|
||||||
pytest-randomly = "^3.16.0"
|
pytest-randomly = "^3.16.0"
|
||||||
ruff = "^0.9.2"
|
ruff = "^0.9.2"
|
||||||
tox = "^4.23.2"
|
tox = "^4.23.2"
|
||||||
@@ -91,14 +91,16 @@ target-version = "py310"
|
|||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
||||||
|
# Enable flake8-errmsg (EM) warnings.
|
||||||
|
# Enable flake8-bugbear (B) warnings.
|
||||||
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
|
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
|
||||||
# McCabe complexity (`C901`) by default.
|
# McCabe complexity (`C901`) by default.
|
||||||
select = ["E4", "E7", "E9", "F"]
|
select = ["E4", "E7", "E9", "EM", "F", "B"]
|
||||||
ignore = []
|
ignore = []
|
||||||
|
|
||||||
# Allow fix for all enabled rules (when `--fix`) is provided.
|
# Allow fix for all enabled rules (when `--fix`) is provided.
|
||||||
fixable = ["ALL"]
|
fixable = ["ALL"]
|
||||||
unfixable = []
|
unfixable = ["B"]
|
||||||
|
|
||||||
# Allow unused variables when underscore-prefixed.
|
# Allow unused variables when underscore-prefixed.
|
||||||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import abc
|
|
||||||
import logging
|
import logging
|
||||||
from enum import IntEnum
|
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from .bus import request_bus_obj as bus
|
from .bus import request_bus_obj as bus
|
||||||
from .command import Command
|
from .command import Command
|
||||||
from .config import request_config as configs
|
from .config import request_config as configs
|
||||||
|
from .enums import KindId
|
||||||
from .error import VBANCMDError
|
from .error import VBANCMDError
|
||||||
from .kinds import KindMapClass
|
from .kinds import KindMapClass
|
||||||
from .kinds import request_kind_map as kindmap
|
from .kinds import request_kind_map as kindmap
|
||||||
@@ -26,28 +25,11 @@ class FactoryBuilder:
|
|||||||
Separates construction from representation.
|
Separates construction from representation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
BuilderProgress = IntEnum(
|
|
||||||
'BuilderProgress', 'strip bus command macrobutton vban recorder', start=0
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, factory, kind: KindMapClass):
|
def __init__(self, factory, kind: KindMapClass):
|
||||||
self._factory = factory
|
self._factory = factory
|
||||||
self.kind = kind
|
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 recorder for {self._factory}',
|
|
||||||
)
|
|
||||||
self.logger = logger.getChild(self.__class__.__name__)
|
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):
|
def make_strip(self):
|
||||||
self._factory.strip = tuple(
|
self._factory.strip = tuple(
|
||||||
strip(i < self.kind.phys_in, self._factory, i)
|
strip(i < self.kind.phys_in, self._factory, i)
|
||||||
@@ -122,11 +104,6 @@ class FactoryBase(VbanCmd):
|
|||||||
+ f"({self.kind}, ip='{self.ip}', port={self.port}, streamname='{self.streamname}')"
|
+ f"({self.kind}, ip='{self.ip}', port={self.port}, streamname='{self.streamname}')"
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
@abc.abstractmethod
|
|
||||||
def steps(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def configs(self):
|
def configs(self):
|
||||||
self._configs = configs(self.kind.name)
|
self._configs = configs(self.kind.name)
|
||||||
@@ -142,12 +119,14 @@ class BasicFactory(FactoryBase):
|
|||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
if cls is BasicFactory:
|
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)
|
return object.__new__(cls)
|
||||||
|
|
||||||
def __init__(self, kind_id, **kwargs):
|
def __init__(self, kind_id, **kwargs):
|
||||||
super().__init__(kind_id, **kwargs)
|
super().__init__(kind_id, **kwargs)
|
||||||
[step()._pinfo(step.__name__) for step in self.steps]
|
for step in self.steps:
|
||||||
|
step()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def steps(self) -> Iterable:
|
def steps(self) -> Iterable:
|
||||||
@@ -164,12 +143,14 @@ class BananaFactory(FactoryBase):
|
|||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
if cls is BananaFactory:
|
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)
|
return object.__new__(cls)
|
||||||
|
|
||||||
def __init__(self, kind_id, **kwargs):
|
def __init__(self, kind_id, **kwargs):
|
||||||
super().__init__(kind_id, **kwargs)
|
super().__init__(kind_id, **kwargs)
|
||||||
[step()._pinfo(step.__name__) for step in self.steps]
|
for step in self.steps:
|
||||||
|
step()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def steps(self) -> Iterable:
|
def steps(self) -> Iterable:
|
||||||
@@ -186,12 +167,14 @@ class PotatoFactory(FactoryBase):
|
|||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
if cls is PotatoFactory:
|
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)
|
return object.__new__(cls)
|
||||||
|
|
||||||
def __init__(self, kind_id: str, **kwargs):
|
def __init__(self, kind_id: str, **kwargs):
|
||||||
super().__init__(kind_id, **kwargs)
|
super().__init__(kind_id, **kwargs)
|
||||||
[step()._pinfo(step.__name__) for step in self.steps]
|
for step in self.steps:
|
||||||
|
step()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def steps(self) -> Iterable:
|
def steps(self) -> Iterable:
|
||||||
@@ -219,7 +202,8 @@ def vbancmd_factory(kind_id: str, **kwargs) -> VbanCmd:
|
|||||||
kind_id = 'potato'
|
kind_id = 'potato'
|
||||||
_factory = PotatoFactory
|
_factory = PotatoFactory
|
||||||
case _:
|
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'VbanCmd{kind_id.capitalize()}', (_factory,), {})(kind_id, **kwargs)
|
return type(f'VbanCmd{kind_id.capitalize()}', (_factory,), {})(kind_id, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@@ -235,6 +219,6 @@ def request_vbancmd_obj(kind_id: str, **kwargs) -> VbanCmd:
|
|||||||
try:
|
try:
|
||||||
VBANCMD_obj = vbancmd_factory(kind_id, **kwargs)
|
VBANCMD_obj = vbancmd_factory(kind_id, **kwargs)
|
||||||
except (ValueError, TypeError) as e:
|
except (ValueError, TypeError) as e:
|
||||||
logger_entry.exception(f'{type(e).__name__}: {e}')
|
logger_entry.error(f'{type(e).__name__}: {e}')
|
||||||
raise VBANCMDError(str(e)) from e
|
raise VBANCMDError(str(e)) from e
|
||||||
return VBANCMD_obj
|
return VBANCMD_obj
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class Subject:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Adds support for observers and callbacks"""
|
"""Adds support for observers and callbacks"""
|
||||||
|
|
||||||
self._observers = list()
|
self._observers = []
|
||||||
self.logger = logger.getChild(self.__class__.__name__)
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -34,15 +34,13 @@ class Subject:
|
|||||||
for o in iterator:
|
for o in iterator:
|
||||||
if o not in self._observers:
|
if o not in self._observers:
|
||||||
self._observers.append(o)
|
self._observers.append(o)
|
||||||
self.logger.info(f'{o} added to event observers')
|
|
||||||
else:
|
else:
|
||||||
self.logger.error(f'Failed to add {o} to event observers')
|
self.logger.debug(f'Failed to add {o} to event observers')
|
||||||
except TypeError:
|
except TypeError:
|
||||||
if observer not in self._observers:
|
if observer not in self._observers:
|
||||||
self._observers.append(observer)
|
self._observers.append(observer)
|
||||||
self.logger.info(f'{observer} added to event observers')
|
|
||||||
else:
|
else:
|
||||||
self.logger.error(f'Failed to add {observer} to event observers')
|
self.logger.debug(f'Failed to add {observer} to event observers')
|
||||||
|
|
||||||
register = add
|
register = add
|
||||||
|
|
||||||
@@ -54,15 +52,13 @@ class Subject:
|
|||||||
for o in iterator:
|
for o in iterator:
|
||||||
try:
|
try:
|
||||||
self._observers.remove(o)
|
self._observers.remove(o)
|
||||||
self.logger.info(f'{o} removed from event observers')
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.logger.error(f'Failed to remove {o} from event observers')
|
self.logger.debug(f'Failed to remove {o} from event observers')
|
||||||
except TypeError:
|
except TypeError:
|
||||||
try:
|
try:
|
||||||
self._observers.remove(observer)
|
self._observers.remove(observer)
|
||||||
self.logger.info(f'{observer} removed from event observers')
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.logger.error(f'Failed to remove {observer} from event observers')
|
self.logger.debug(f'Failed to remove {observer} from event observers')
|
||||||
|
|
||||||
deregister = remove
|
deregister = remove
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,4 @@ def deep_merge(dict1, dict2):
|
|||||||
|
|
||||||
def bump_framecounter(framecounter: int) -> int:
|
def bump_framecounter(framecounter: int) -> int:
|
||||||
"""Increment framecounter with rollover at 0xFFFFFFFF."""
|
"""Increment framecounter with rollover at 0xFFFFFFFF."""
|
||||||
if framecounter > 0xFFFFFFFF:
|
return (framecounter + 1) & 0xFFFFFFFF
|
||||||
return 0
|
|
||||||
else:
|
|
||||||
return framecounter + 1
|
|
||||||
|
|||||||
@@ -56,9 +56,10 @@ class VbanCmd(abc.ABC):
|
|||||||
self.producer = None
|
self.producer = None
|
||||||
self._last_script_request_time = 0
|
self._last_script_request_time = 0
|
||||||
|
|
||||||
|
@property
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def __str__(self):
|
def steps(self):
|
||||||
"""Ensure subclasses override str magic method"""
|
"""Steps required to build the interface for this Voicemeeter kind"""
|
||||||
|
|
||||||
def _conn_from_toml(self) -> dict:
|
def _conn_from_toml(self) -> dict:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user