Skip to content

Commit

Permalink
fixes for python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
eavanvalkenburg committed Apr 29, 2021
1 parent 7008f4f commit e50bc7b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions src/pysiaalarm/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
)
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit e50bc7b

Please sign in to comment.