Skip to content

Commit 2893a07

Browse files
chore(pre-commit.ci): auto fixes
1 parent 5c5aad3 commit 2893a07

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

onvif/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ async def create_pullpoint_manager(
563563
topic_filter: str | None = None,
564564
) -> PullPointManager:
565565
"""Create a pullpoint manager."""
566-
manager = PullPointManager(self, interval, subscription_lost_callback, topic_filter)
566+
manager = PullPointManager(
567+
self, interval, subscription_lost_callback, topic_filter
568+
)
567569
await manager.start()
568570
return manager
569571

onvif/managers.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
from typing import TYPE_CHECKING, Any
1111

1212

13-
from lxml.etree import XPath, XPathSyntaxError
14-
from zeep.client import Client
13+
from lxml.etree import XPath
1514
from zeep.exceptions import Fault, XMLParseError, XMLSyntaxError
1615
from zeep.loader import parse_xml
1716
from zeep.wsdl.bindings.soap import SoapOperation
18-
from zeep.xsd import Element, AnyObject
1917

2018
import aiohttp
2119
from onvif.exceptions import ONVIFError
@@ -57,7 +55,11 @@ def __init__(
5755
) -> None:
5856
"""Initialize the notification processor."""
5957
self._device = device
60-
self._interval = interval if interval <= MINIMUM_SUBSCRIPTION_INTERVAL else MINIMUM_SUBSCRIPTION_INTERVAL
58+
self._interval = (
59+
interval
60+
if interval <= MINIMUM_SUBSCRIPTION_INTERVAL
61+
else MINIMUM_SUBSCRIPTION_INTERVAL
62+
)
6163
self._subscription: ONVIFService | None = None
6264
self._restart_or_renew_task: asyncio.Task | None = None
6365
self._loop = asyncio.get_event_loop()
@@ -298,11 +300,11 @@ class PullPointManager(BaseManager):
298300
"""Manager for PullPoint."""
299301

300302
def __init__(
301-
self,
302-
device: ONVIFCamera,
303-
interval: dt.timedelta,
304-
subscription_lost_callback: Callable[[], None],
305-
topic_filter: TopicExpression | None = None,
303+
self,
304+
device: ONVIFCamera,
305+
interval: dt.timedelta,
306+
subscription_lost_callback: Callable[[], None],
307+
topic_filter: TopicExpression | None = None,
306308
) -> None:
307309
"""
308310
Create a Manager for PullPoint
@@ -321,7 +323,9 @@ def __init__(
321323
>>> PullPointManager(cam, timedelta(seconds=60), lambda: print("Lost connection!"), "tns1:RuleEngine/CellMotionDetector/Motion")
322324
323325
"""
324-
self._topic_filter: str | None = XPath(topic_filter).path if topic_filter else None
326+
self._topic_filter: str | None = (
327+
XPath(topic_filter).path if topic_filter else None
328+
)
325329
super().__init__(device, interval, subscription_lost_callback)
326330

327331
async def _start(self) -> float:
@@ -335,21 +339,19 @@ async def _start(self) -> float:
335339
events_service = await device.create_events_service()
336340

337341
subscription_params = {
338-
"InitialTerminationTime": device.get_next_termination_time(
339-
self._interval
340-
),
342+
"InitialTerminationTime": device.get_next_termination_time(self._interval),
341343
}
342344
# Alternatively, filter could be accepted as an argument
343345
# and we can expect the caller to create the TopicExpression
344346
# this would allow them to control the dialect too?
345347
if self._topic_filter:
346348
subscription_params["Filter"] = {
347-
"_value_1": TopicExpression.from_client(events_service.zeep_client, self._topic_filter),
349+
"_value_1": TopicExpression.from_client(
350+
events_service.zeep_client, self._topic_filter
351+
),
348352
}
349353

350-
result = await events_service.CreatePullPointSubscription(
351-
subscription_params
352-
)
354+
result = await events_service.CreatePullPointSubscription(subscription_params)
353355
# pylint: disable=protected-access
354356

355357
device.xaddrs[

onvif/types.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,18 @@ class TopicExpression(AnyObject):
110110
NAMESPACE = "{http://docs.oasis-open.org/wsn/b-2}"
111111
DIALECT = "http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet"
112112

113-
def __init__(self, topic_expression_type: ComplexType, value: str, dialect: str = DIALECT):
113+
def __init__(
114+
self, topic_expression_type: ComplexType, value: str, dialect: str = DIALECT
115+
):
114116
expression = Element(f"{self.NAMESPACE}TopicExpression", topic_expression_type)
115-
super().__init__(expression, topic_expression_type(_value_1=value, Dialect=dialect))
116-
117+
super().__init__(
118+
expression, topic_expression_type(_value_1=value, Dialect=dialect)
119+
)
120+
117121
@classmethod
118-
def from_client(cls, client: Client, expression: str, dialect: str = DIALECT) -> "TopicExpression":
119-
return cls(client.get_type(f"{cls.NAMESPACE}TopicExpressionType"), expression, dialect)
120-
122+
def from_client(
123+
cls, client: Client, expression: str, dialect: str = DIALECT
124+
) -> "TopicExpression":
125+
return cls(
126+
client.get_type(f"{cls.NAMESPACE}TopicExpressionType"), expression, dialect
127+
)

0 commit comments

Comments
 (0)