mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
STAR-322: Fixing printer matching by network key
This commit is contained in:
parent
cd67100097
commit
7e76913736
5 changed files with 97 additions and 64 deletions
19
plugins/UM3NetworkPrinting/src/Cloud/Utils.py
Normal file
19
plugins/UM3NetworkPrinting/src/Cloud/Utils.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from typing import TypeVar, Dict, Tuple, List
|
||||
|
||||
T = TypeVar("T")
|
||||
U = TypeVar("U")
|
||||
|
||||
|
||||
def findChanges(previous: Dict[str, T], received: Dict[str, U]) -> Tuple[List[T], List[U], List[Tuple[T, U]]]:
|
||||
previous_ids = set(previous)
|
||||
received_ids = set(received)
|
||||
|
||||
removed_ids = previous_ids.difference(received_ids)
|
||||
new_ids = received_ids.difference(previous_ids)
|
||||
updated_ids = received_ids.intersection(previous_ids)
|
||||
|
||||
removed = [previous[removed_id] for removed_id in removed_ids]
|
||||
added = [received[new_id] for new_id in new_ids]
|
||||
updated = [(previous[updated_id], received[updated_id]) for updated_id in updated_ids]
|
||||
|
||||
return removed, added, updated
|
Loading…
Add table
Add a link
Reference in a new issue