From e50bc7b4a77aecb99376eb7ea882e725cc526f0e Mon Sep 17 00:00:00 2001 From: Eduard van Valkenburg Date: Thu, 29 Apr 2021 14:55:03 +0000 Subject: [PATCH] fixes for python 3.8 --- .devcontainer/devcontainer.json | 2 +- setup.cfg | 2 +- src/pysiaalarm/event.py | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1f83ae7..93b2d95 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,7 +7,7 @@ "context": "..", "args": { // Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9 - "VARIANT": "3.9", + "VARIANT": "3.8", // Options "INSTALL_NODE": "false", "NODE_VERSION": "lts/*" diff --git a/setup.cfg b/setup.cfg index caedf56..e4f13a4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,7 +34,7 @@ package_dir = =src # Require a min/specific Python version (comma-separated conditions) -python_requires = >=3.7 +python_requires = >=3.8 # Add here dependencies of your project (line-separated), e.g. requests>=2.2,<3.0. # Version specifiers like >=2.2,<3.0 avoid problems due to API changes in diff --git a/src/pysiaalarm/event.py b/src/pysiaalarm/event.py index 237ae39..acf5d01 100644 --- a/src/pysiaalarm/event.py +++ b/src/pysiaalarm/event.py @@ -6,7 +6,7 @@ from dataclasses import dataclass, field from dataclasses_json import dataclass_json, config, Exclude from datetime import datetime, timedelta, timezone -from typing import Dict, Optional, Union +from typing import Dict, Optional, Union, List from Crypto.Cipher import AES from Crypto.Cipher._mode_cbc import CbcMode @@ -57,7 +57,6 @@ class BaseEvent(ABC): code: Optional[str] = None message: Optional[str] = None x_data: Optional[str] = None - x_data_list: Optional[list[str]] = None timestamp: Optional[datetime] = None # From ADM-CID @@ -67,7 +66,7 @@ class BaseEvent(ABC): # Parsed fields calc_crc: Optional[str] = None - extended_data: Optional[list[SIAXData]] = None + extended_data: Optional[List[SIAXData]] = None sia_account: Optional[SIAAccount] = field( metadata=config(exclude=Exclude.ALWAYS), default=None # type: ignore ) @@ -408,15 +407,16 @@ def parse_content(self) -> None: def parse_extended_data(self) -> None: """Set extended data.""" - if self.x_data is not None: # pragma: no cover - self.x_data_list = self.x_data.split("][") - self.extended_data = [] - for xd in self.x_data_list: - xdata = _load_xdata().get(xd[0], None) - if xdata: - xdata.value = xd[1:] - self.extended_data.append(xdata) - self._xdata_parsed = True + if self.x_data is None: # pragma: no cover + return + x_data_list = self.x_data.split("][") + self.extended_data = [] + for xd in x_data_list: # pragma: no cover + xdata = _load_xdata().get(xd[0], None) + if xdata: + xdata.value = xd[1:] + self.extended_data.append(xdata) + self._xdata_parsed = True def sia_account_from_message(self) -> Optional[SIAAccount]: # pragma: no cover """Return the SIA Account, if there is not account added, create one based on the account in the message."""