Projekt

Obecné

Profil

Stáhnout (756 Bajtů) Statistiky
| Větev: | Revize:
1 2f227a6c ballakt
from typing import Dict
2
3 81980e82 ballakt
SKIP = "SKIP"
4
UNKNOWN = "UNKNOWN!"
5
6
7
def should_skip(device) -> bool:
8
    return device['x'] == SKIP or device['y'] == SKIP or device[
9
        'x'] == UNKNOWN or device['y'] == UNKNOWN
10 2f227a6c ballakt
11
12
def detect_change(first: Dict[str, str], second: Dict[str, str], compareKeys: [str]) -> bool:
13
    """Detects change between two dictonaries
14
15
    Args:
16
        first (Dict[str, str]): First dictionary
17
        second (Dict[str, str]): Second dictionary
18
        compareKeys ([type]): Keys to handle comparison
19
20
    Returns:
21
        bool: Is there a change ?
22
    """
23
    for key in compareKeys:
24
        if key not in second or key not in first:
25
            return True
26
        if first[key] != second[key]:
27
            return True
28
    return False