Skip to content

Commit

Permalink
more dict comprehensions
Browse files Browse the repository at this point in the history
  • Loading branch information
farmio committed Oct 21, 2023
1 parent 2043b5a commit d1d6e05
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions xknxproject/xml/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,35 +324,36 @@ def _transform(self) -> KNXProject:
name=area.name, description=area.description, lines=lines_dict
)

group_address_dict: dict[str, GroupAddress] = {}
for group_address in self.group_addresses:
_com_object_ids = [
com_object_id
for com_object_id, com_object in communication_objects.items()
if group_address.address in com_object["group_address_links"]
]
group_address_dict[group_address.address] = GroupAddress(
group_address_dict: dict[str, GroupAddress] = {
group_address.address: GroupAddress(
name=group_address.name,
identifier=group_address.identifier,
raw_address=group_address.raw_address,
address=group_address.address,
project_uid=group_address.project_uid,
dpt=group_address.dpt,
data_secure=bool(group_address.data_secure_key),
communication_object_ids=_com_object_ids,
communication_object_ids=[
com_object_id
for com_object_id, com_object in communication_objects.items()
if group_address.address in com_object["group_address_links"]
],
description=group_address.description,
comment=html.unescape(rtf_to_text(group_address.comment)),
)
for group_address in self.group_addresses
}

group_range_dict: dict[str, GroupRange] = _recursive_convert_group_range(
self.group_ranges, group_address_style=self.project_info.group_address_style
self.group_ranges, self.project_info.group_address_style
)

space_dict: dict[str, Space] = _recursive_convert_spaces(self.spaces)

functions_dict: dict[str, Function] = {}
for function in self.functions:
functions_dict[function.identifier] = _convert_functions(function)
functions_dict: dict[str, Function] = {
function.identifier: _convert_functions(function)
for function in self.functions
}

info = ProjectInfo(
project_id=self.project_info.project_id,
Expand Down

0 comments on commit d1d6e05

Please sign in to comment.