aioccl 2024.12.2__tar.gz → 2024.12.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioccl
3
- Version: 2024.12.2
3
+ Version: 2024.12.5
4
4
  Summary: A Python library for CCL API server
5
5
  Home-page: https://github.com/fkiscd/aioccl
6
6
  Download-URL: https://github.com/fkiscd/aioccl
@@ -13,7 +13,7 @@ class CCLSensor:
13
13
  """Initialize a CCL sensor."""
14
14
  self._value: None | str | int | float = None
15
15
 
16
- if key in CCL_SENSORS.keys():
16
+ if key in CCL_SENSORS:
17
17
  self._key = key
18
18
 
19
19
  @property
@@ -34,7 +34,7 @@ class CCLSensor:
34
34
  @property
35
35
  def compartment(self) -> None | str:
36
36
  """Decide which compartment it belongs to."""
37
- if CCL_SENSORS[self._key].compartment is not None:
37
+ if CCL_SENSORS[self._key].compartment:
38
38
  return CCL_SENSORS[self._key].compartment.value
39
39
 
40
40
  @property
@@ -49,7 +49,8 @@ class CCLSensor:
49
49
  return CCL_SENSOR_VALUES[self.sensor_type.name].get(self._value)
50
50
  elif self.sensor_type == CCLSensorTypes.BATTERY_BINARY:
51
51
  try:
52
- return int(self._value) - 1
52
+ x = int(self._value) - 1
53
+ return x
53
54
  except ValueError:
54
55
  pass
55
56
  else:
@@ -24,15 +24,10 @@ class CCLServer:
24
24
  def register(device: CCLDevice) -> None:
25
25
  """Register a device with a passkey."""
26
26
  CCLServer.devices.setdefault(device.passkey, device)
27
- _LOGGER.debug("Device registered: %s", CCLServer.devices)
28
-
29
- @staticmethod
30
- def get_handler() -> Callable[[web.BaseRequest], web.Response]:
31
- """Get the handler."""
32
- return CCLServer._handler
27
+ _LOGGER.debug("Device registered: %s", device)
33
28
 
34
29
  @staticmethod
35
- async def _handler(request: web.BaseRequest) -> web.Response:
30
+ async def handler(request: web.BaseRequest | web.Request) -> web.Response:
36
31
  """Handle POST requests for data updating."""
37
32
  _body: dict[str, None | str | int | float] = {}
38
33
  _device: CCLDevice = None
@@ -43,11 +38,12 @@ class CCLServer:
43
38
  _text: None | str = None
44
39
 
45
40
  try:
46
- for passkey, _device in CCLServer.devices.items():
47
- if passkey == request.match_info["passkey"]:
48
- _passkey = passkey
41
+ _passkey = request.path[-8:]
42
+ for passkey in CCLServer.devices:
43
+ if passkey == _passkey:
44
+ _device = CCLServer.devices[_passkey]
49
45
  break
50
- assert _device, 404
46
+ assert isinstance(_device, CCLDevice), 404
51
47
 
52
48
  assert request.content_type == "application/json", 400
53
49
  assert 0 < request.content_length <= 5000, 400
@@ -81,7 +77,7 @@ class CCLServer:
81
77
  return web.Response(status=_status, text=_text)
82
78
 
83
79
  app = web.Application()
84
- app.add_routes([web.get('/{passkey}', _handler)])
80
+ app.add_routes([web.get('/{passkey}', handler)])
85
81
  runner = web.AppRunner(app)
86
82
 
87
83
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioccl
3
- Version: 2024.12.2
3
+ Version: 2024.12.5
4
4
  Summary: A Python library for CCL API server
5
5
  Home-page: https://github.com/fkiscd/aioccl
6
6
  Download-URL: https://github.com/fkiscd/aioccl
@@ -3,7 +3,7 @@
3
3
  from pathlib import Path
4
4
  from setuptools import find_packages, setup
5
5
 
6
- VERSION = "2024.12.2"
6
+ VERSION = "2024.12.5"
7
7
 
8
8
  ROOT_DIR = Path(__file__).parent.resolve()
9
9
 
File without changes
File without changes
File without changes
File without changes