Skip to content

Commit

Permalink
Run black
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincar committed Mar 6, 2024
1 parent 059de19 commit b1e6470
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions bless/backends/bluezdbus/dbus/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ class BlueZGattApplication(ServiceInterface):
org.bluez.GattApplication1 interface implementation
"""

def __init__(
self,
name: str,
destination: str,
bus: MessageBus
):
def __init__(self, name: str, destination: str, bus: MessageBus):
"""
Initialize a new GattApplication1
Expand All @@ -48,18 +43,14 @@ def __init__(
self.bus: MessageBus = bus

# Valid path must be ASCII characters "[A-Z][a-z][0-9]_"
# see https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path
# see https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path # noqa E501

self.base_path: str = (
"/org/bluez/" + re.sub( '[^A-Za-z0-9_]', '', self.app_name )
)
self.base_path: str = "/org/bluez/" + re.sub("[^A-Za-z0-9_]", "", self.app_name)
self.advertisements: List[BlueZLEAdvertisement] = []
self.services: List[BlueZGattService] = []

self.Read: Optional[Callable[[BlueZGattCharacteristic], bytes]] = None
self.Write: Optional[
Callable[[BlueZGattCharacteristic, bytes], None]
] = None
self.Write: Optional[Callable[[BlueZGattCharacteristic, bytes], None]] = None
self.StartNotify: Optional[Callable[[None], None]] = None
self.StopNotify: Optional[Callable[[None], None]] = None

Expand Down Expand Up @@ -131,7 +122,7 @@ async def set_name(self, adapter: ProxyObject, name: str):
"""
iface: ProxyInterface = adapter.get_interface("org.freedesktop.DBus.Properties")
await iface.call_set( # type: ignore
"org.bluez.Adapter1", "Alias", Variant('s', name)
"org.bluez.Adapter1", "Alias", Variant("s", name)
)

async def register(self, adapter: ProxyObject):
Expand All @@ -144,10 +135,7 @@ async def register(self, adapter: ProxyObject):
The adapter to register the application with
"""
iface: ProxyInterface = adapter.get_interface(defs.GATT_MANAGER_INTERFACE)
await iface.call_register_application( # type: ignore
self.path,
{}
)
await iface.call_register_application(self.path, {}) # type: ignore

async def unregister(self, adapter: ProxyObject):
"""
Expand All @@ -159,9 +147,7 @@ async def unregister(self, adapter: ProxyObject):
The adapter on which the current application is registered
"""
iface: ProxyInterface = adapter.get_interface(defs.GATT_MANAGER_INTERFACE)
await iface.call_unregister_application( # type: ignore
self.path
)
await iface.call_unregister_application(self.path) # type: ignore

async def start_advertising(self, adapter: ProxyObject):
"""
Expand All @@ -185,9 +171,7 @@ async def start_advertising(self, adapter: ProxyObject):
self.bus.export(advertisement.path, advertisement)

iface: ProxyInterface = adapter.get_interface("org.bluez.LEAdvertisingManager1")
await iface.call_register_advertisement( # type: ignore
advertisement.path, {}
)
await iface.call_register_advertisement(advertisement.path, {}) # type: ignore

async def is_advertising(self, adapter: ProxyObject) -> bool:
"""
Expand All @@ -205,8 +189,7 @@ async def is_advertising(self, adapter: ProxyObject) -> bool:
"""
iface: ProxyInterface = adapter.get_interface(defs.PROPERTIES_INTERFACE)
instances: Variant = await iface.call_get( # type: ignore
"org.bluez.LEAdvertisingManager1",
"ActiveInstances"
"org.bluez.LEAdvertisingManager1", "ActiveInstances"
)
return instances.value > 0

Expand All @@ -222,9 +205,7 @@ async def stop_advertising(self, adapter: ProxyObject):
await self.set_name(adapter, "")
advertisement: BlueZLEAdvertisement = self.advertisements.pop()
iface: ProxyInterface = adapter.get_interface("org.bluez.LEAdvertisingManager1")
await iface.call_unregister_advertisement( # type: ignore
advertisement.path
)
await iface.call_unregister_advertisement(advertisement.path) # type: ignore
self.bus.unexport(advertisement.path)

async def is_connected(self) -> bool:
Expand Down

0 comments on commit b1e6470

Please sign in to comment.