Projekt

Obecné

Profil

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